mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
mem: Panic when passing invalid pointers to small stack free/resize
This is consistent with `Stack_Allocator`.
This commit is contained in:
@@ -1387,8 +1387,7 @@ small_stack_free :: proc(
|
|||||||
end := start + uintptr(len(s.data))
|
end := start + uintptr(len(s.data))
|
||||||
curr_addr := uintptr(old_memory)
|
curr_addr := uintptr(old_memory)
|
||||||
if !(start <= curr_addr && curr_addr < end) {
|
if !(start <= curr_addr && curr_addr < end) {
|
||||||
// panic("Out of bounds memory address passed to stack allocator (free)");
|
panic("Out of bounds memory address passed to small stack allocator (free)", loc)
|
||||||
return .Invalid_Pointer
|
|
||||||
}
|
}
|
||||||
if curr_addr >= start+uintptr(s.offset) {
|
if curr_addr >= start+uintptr(s.offset) {
|
||||||
// NOTE(bill): Allow double frees
|
// NOTE(bill): Allow double frees
|
||||||
@@ -1543,8 +1542,7 @@ small_stack_resize_bytes_non_zeroed :: proc(
|
|||||||
end := start + uintptr(len(s.data))
|
end := start + uintptr(len(s.data))
|
||||||
curr_addr := uintptr(old_memory)
|
curr_addr := uintptr(old_memory)
|
||||||
if !(start <= curr_addr && curr_addr < end) {
|
if !(start <= curr_addr && curr_addr < end) {
|
||||||
// panic("Out of bounds memory address passed to stack allocator (resize)");
|
panic("Out of bounds memory address passed to small stack allocator (resize)", loc)
|
||||||
return nil, .Invalid_Pointer
|
|
||||||
}
|
}
|
||||||
if curr_addr >= start+uintptr(s.offset) {
|
if curr_addr >= start+uintptr(s.offset) {
|
||||||
// NOTE(bill): Treat as a double free
|
// NOTE(bill): Treat as a double free
|
||||||
|
|||||||
Reference in New Issue
Block a user