From aa41a77fc44db838c15aadbd405a11d26c5ddb80 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Sat, 14 Jun 2025 13:08:50 -0400 Subject: [PATCH] mem: Check if `alignment` matches on `Small_Stack` resize --- core/mem/allocators.odin | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/mem/allocators.odin b/core/mem/allocators.odin index 30c2589e7..200f15883 100644 --- a/core/mem/allocators.odin +++ b/core/mem/allocators.odin @@ -1550,6 +1550,16 @@ small_stack_resize_bytes_non_zeroed :: proc( // NOTE(bill): Treat as a double free return nil, nil } + if uintptr(old_memory) & uintptr(alignment-1) != 0 { + // A different alignment has been requested and the current address + // does not satisfy it. + data, err := small_stack_alloc_bytes_non_zeroed(s, size, alignment, loc) + if err == nil { + runtime.copy(data, byte_slice(old_memory, old_size)) + sanitizer.address_poison(old_memory) + } + return data, err + } if old_size == size { result := byte_slice(old_memory, size) sanitizer.address_unpoison(result)