소스 검색

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 달 전
부모
커밋
591dd8765a
1개의 변경된 파일0개의 추가작업 그리고 1개의 파일을 삭제
  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[:])
 }