Merge pull request #2531 from jasonKercher/fix2530

add nil check to heap_alloc calls (issue 2530)
This commit is contained in:
Jeroen van Rijn
2023-05-11 20:20:03 +02:00
committed by GitHub
4 changed files with 4 additions and 4 deletions

View File

@@ -194,7 +194,7 @@ heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
ptr := uintptr(aligned_mem)
aligned_ptr := (ptr - 1 + uintptr(a)) & -uintptr(a)
diff := int(aligned_ptr - ptr)
if (size + diff) > space {
if (size + diff) > space || allocated_mem == nil {
return nil, .Out_Of_Memory
}

View File

@@ -166,7 +166,7 @@ _heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
ptr := uintptr(aligned_mem)
aligned_ptr := (ptr - 1 + uintptr(a)) & -uintptr(a)
diff := int(aligned_ptr - ptr)
if (size + diff) > space {
if (size + diff) > space || allocated_mem == nil {
return nil, .Out_Of_Memory
}

View File

@@ -52,7 +52,7 @@ _heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
ptr := uintptr(aligned_mem)
aligned_ptr := (ptr - 1 + uintptr(a)) & -uintptr(a)
diff := int(aligned_ptr - ptr)
if (size + diff) > space {
if (size + diff) > space || allocated_mem == nil {
return nil, .Out_Of_Memory
}

View File

@@ -112,7 +112,7 @@ _windows_default_alloc_or_resize :: proc "contextless" (size, alignment: int, ol
ptr := uintptr(aligned_mem)
aligned_ptr := (ptr - 1 + uintptr(a)) & -uintptr(a)
diff := int(aligned_ptr - ptr)
if (size + diff) > space {
if (size + diff) > space || allocated_mem == nil {
return nil, .Out_Of_Memory
}