From 7e77bd425f91be572644a6be8f1d1627a0fee7d1 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Sun, 15 Jun 2025 07:29:51 -0400 Subject: [PATCH] mem: Guard against size 0 in `dynamic_arena_resize_*` --- core/mem/allocators.odin | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/mem/allocators.odin b/core/mem/allocators.odin index 300b82d47..e0d3b323c 100644 --- a/core/mem/allocators.odin +++ b/core/mem/allocators.odin @@ -1912,6 +1912,10 @@ dynamic_arena_resize_bytes :: proc( size: int, loc := #caller_location, ) -> ([]byte, Allocator_Error) { + if size == 0 { + // NOTE: This allocator has no Free mode. + return nil, nil + } bytes, err := dynamic_arena_resize_bytes_non_zeroed(a, old_data, size, loc) if bytes != nil { if old_data == nil { @@ -1968,6 +1972,10 @@ dynamic_arena_resize_bytes_non_zeroed :: proc( size: int, loc := #caller_location, ) -> ([]byte, Allocator_Error) { + if size == 0 { + // NOTE: This allocator has no Free mode. + return nil, nil + } old_memory := raw_data(old_data) old_size := len(old_data) if old_size >= size {