mem: Check if alignment matches on Stack_Allocator resize

This commit is contained in:
Feoramund
2025-06-14 12:00:17 -04:00
parent 837d8cf72c
commit ae96b276c1

View File

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