kernel/guarded_heap: allocate_meta may fail with certain flags set.

May fix #20014.
This commit is contained in:
Augustin Cavalier
2026-03-30 18:33:23 -04:00
parent 75b91674e9
commit d6c0df2394
+7
View File
@@ -159,6 +159,9 @@ guarded_heap_allocate_meta(guarded_heap& heap, size_t size, uint32 flags)
}
void* meta = heap.meta_allocator.Allocate(size);
if (meta == NULL)
return NULL;
memset(meta, 0, size);
return meta;
}
@@ -260,6 +263,10 @@ guarded_heap_allocate(guarded_heap& heap, size_t size, size_t alignment,
// need to unlock the heap to allocate more.
GuardedHeapChunk* spareChunk = (GuardedHeapChunk*)
guarded_heap_allocate_meta(heap, sizeof(GuardedHeapChunk), flags);
if (spareChunk == NULL) {
// Various flags can cause this even if there's still memory left.
return NULL;
}
// Round up to the page size, plus the guard pages on either end.
const size_t guardPages = 1;