mem: Check if alignment matches on Small_Stack resize

This commit is contained in:
Feoramund
2025-06-14 13:08:50 -04:00
parent 3a02918efc
commit aa41a77fc4

View File

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