From 591dd8765adb04ff5e0ba66c4c583ea49dbbcc87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20K=C3=A9ri?= Date: Mon, 30 Dec 2024 12:00:38 +0100 Subject: [PATCH] encoding/base32: Remove incorrect defer delete in encode() Remove premature deallocation of the output buffer which was causing use-after-free behavior. The returned string needs to take ownership of this memory, but the defer delete was freeing it before the string could be used. This fixes issues with encoding that were introduced by overly aggressive memory cleanup in 93238db2. --- core/encoding/base32/base32.odin | 1 - 1 file changed, 1 deletion(-) diff --git a/core/encoding/base32/base32.odin b/core/encoding/base32/base32.odin index 60ece7b26..c46d4a323 100644 --- a/core/encoding/base32/base32.odin +++ b/core/encoding/base32/base32.odin @@ -54,7 +54,6 @@ DEC_TABLE := [256]u8 { encode :: proc(data: []byte, ENC_TBL := ENC_TABLE, allocator := context.allocator) -> string { out_length := (len(data) + 4) / 5 * 8 out := make([]byte, out_length, allocator) - defer delete(out) _encode(out, data, ENC_TBL) return string(out[:]) }