diff --git a/kernel/src/memory/Heap.cpp b/kernel/src/memory/Heap.cpp index 5887e7dc..dc172a83 100644 --- a/kernel/src/memory/Heap.cpp +++ b/kernel/src/memory/Heap.cpp @@ -176,7 +176,7 @@ Result kmalloc(usize size) if (!heap_start) { - const usize pages = get_pages_for_allocation(size); + const usize pages = get_pages_for_allocation(size + sizeof(HeapBlock)); HeapBlock* const block = TRY(allocate_pages(pages)); block->full_size = (pages * ARCH_PAGE_SIZE) - sizeof(HeapBlock); @@ -214,7 +214,7 @@ Result kmalloc(usize size) if (!block) // No free blocks, let's allocate a new one { - usize pages = get_pages_for_allocation(size); + usize pages = get_pages_for_allocation(size + sizeof(HeapBlock)); block = TRY(allocate_pages(pages)); block->full_size = (pages * ARCH_PAGE_SIZE) - sizeof(HeapBlock);