Przeglądaj źródła

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.
Zoltán Kéri 9 miesięcy temu
rodzic
commit
591dd8765a
1 zmienionych plików z 0 dodań i 1 usunięć
  1. 0 1
      core/encoding/base32/base32.odin

+ 0 - 1
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[:])
 }