From 837d8cf72cfa5880defae48f9ef01df8c24d8fbc Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Sat, 14 Jun 2025 11:53:00 -0400 Subject: [PATCH] mem: Actually resize when resizing for `Stack_Allocator` Changed the check from `bytes` to `err` for safety's sake, too. This will prevent the potential bug of allocating non-zero memory, then doing a zeroed resize, which will result in having garbage data in the initial half. --- core/mem/allocators.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/mem/allocators.odin b/core/mem/allocators.odin index 4f6655193..6b8f97ec6 100644 --- a/core/mem/allocators.odin +++ b/core/mem/allocators.odin @@ -1052,8 +1052,8 @@ stack_resize_bytes :: proc( alignment := DEFAULT_ALIGNMENT, loc := #caller_location, ) -> ([]byte, Allocator_Error) { - bytes, err := stack_alloc_bytes_non_zeroed(s, size, alignment, loc) - if bytes != nil { + bytes, err := stack_resize_bytes_non_zeroed(s, old_data, size, alignment, loc) + if err == nil { if old_data == nil { zero_slice(bytes) } else if size > len(old_data) {