diff options
| author | alessio98888 <56458281+alessio98888@users.noreply.github.com> | 2025-08-16 19:50:06 +0200 |
|---|---|---|
| committer | alessio98888 <56458281+alessio98888@users.noreply.github.com> | 2025-08-16 19:50:06 +0200 |
| commit | c6db3cc6709bf53d0bbfafab66769175e9a871ae (patch) | |
| tree | 5f6322afecd0577fe9e75c1d40e03eb5df8b9852 | |
| parent | fb4641307189b6952304dc1b2ff3dccdad75029c (diff) | |
Fix buddy allocator assert
The last address of "data" is not "cast(uintptr)raw_data(data)+cast(uintptr)size" but
"cast(uintptr)raw_data(data)+cast(uintptr)(size-1)".
The original assert would fail when for example the allocation size requested and the buddy allocator allignment were both 64.
| -rw-r--r-- | core/mem/allocators.odin | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/mem/allocators.odin b/core/mem/allocators.odin index cb9301f60..2d7e7b3ea 100644 --- a/core/mem/allocators.odin +++ b/core/mem/allocators.odin @@ -2331,7 +2331,7 @@ buddy_allocator_alloc_bytes_non_zeroed :: proc(b: ^Buddy_Allocator, size: uint) } found.is_free = false data := ([^]byte)(found)[b.alignment:][:size] - assert(cast(uintptr)raw_data(data)+cast(uintptr)size < cast(uintptr)buddy_block_next(found), "Buddy_Allocator has made an allocation which overlaps a block header.") + assert(cast(uintptr)raw_data(data)+cast(uintptr)(size-1) < cast(uintptr)buddy_block_next(found), "Buddy_Allocator has made an allocation which overlaps a block header.") // ensure_poisoned(data) // sanitizer.address_unpoison(data) return data, nil |