diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-06-14 13:08:50 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2025-06-15 12:34:15 -0400 |
| commit | aa41a77fc44db838c15aadbd405a11d26c5ddb80 (patch) | |
| tree | 6f65aac4c33bf20ec98bc78d461f5f32a55fa42f /core | |
| parent | 3a02918efc2cd038bb51c0b3623865cc57d2fa0f (diff) | |
mem: Check if `alignment` matches on `Small_Stack` resize
Diffstat (limited to 'core')
| -rw-r--r-- | core/mem/allocators.odin | 10 |
1 files changed, 10 insertions, 0 deletions
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) |