Explorar el Código

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 hace 9 meses
padre
commit
591dd8765a
Se han modificado 1 ficheros con 0 adiciones y 1 borrados
  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[:])
 }