mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
mem: Guard against size 0 in dynamic_arena_resize_*
This commit is contained in:
@@ -1912,6 +1912,10 @@ dynamic_arena_resize_bytes :: proc(
|
|||||||
size: int,
|
size: int,
|
||||||
loc := #caller_location,
|
loc := #caller_location,
|
||||||
) -> ([]byte, Allocator_Error) {
|
) -> ([]byte, Allocator_Error) {
|
||||||
|
if size == 0 {
|
||||||
|
// NOTE: This allocator has no Free mode.
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
bytes, err := dynamic_arena_resize_bytes_non_zeroed(a, old_data, size, loc)
|
bytes, err := dynamic_arena_resize_bytes_non_zeroed(a, old_data, size, loc)
|
||||||
if bytes != nil {
|
if bytes != nil {
|
||||||
if old_data == nil {
|
if old_data == nil {
|
||||||
@@ -1968,6 +1972,10 @@ dynamic_arena_resize_bytes_non_zeroed :: proc(
|
|||||||
size: int,
|
size: int,
|
||||||
loc := #caller_location,
|
loc := #caller_location,
|
||||||
) -> ([]byte, Allocator_Error) {
|
) -> ([]byte, Allocator_Error) {
|
||||||
|
if size == 0 {
|
||||||
|
// NOTE: This allocator has no Free mode.
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
old_memory := raw_data(old_data)
|
old_memory := raw_data(old_data)
|
||||||
old_size := len(old_data)
|
old_size := len(old_data)
|
||||||
if old_size >= size {
|
if old_size >= size {
|
||||||
|
|||||||
Reference in New Issue
Block a user