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.
This commit is contained in:
Feoramund
2025-06-14 11:53:00 -04:00
parent f701aeffd5
commit 837d8cf72c

View File

@@ -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) {