diff --git a/core/mem/allocators.odin b/core/mem/allocators.odin index 6b8f97ec6..dfb76b101 100644 --- a/core/mem/allocators.odin +++ b/core/mem/allocators.odin @@ -1137,6 +1137,16 @@ stack_resize_bytes_non_zeroed :: proc( // NOTE(bill): Allow double frees 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 := 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 { return byte_slice(old_memory, size), nil }