Heap: Fix GPF caused when making many small allocations
All checks were successful
continuous-integration/drone/pr Build is passing

Apparently space was too tight to split(), but we did it anyways, corrupting the next block.
This patch fixes this behavior.
This commit is contained in:
apio 2023-02-17 22:47:15 +01:00
parent 4697a16206
commit 37bbc04719
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -99,7 +99,7 @@ static Option<HeapBlock*> split(HeapBlock* block, usize size)
const usize old_size =
block->full_size; // Save the old value of this variable since we are going to use it after modifying it
if (available < (size + sizeof(HeapBlock)))
if (available <= (size + sizeof(HeapBlock)))
return {}; // This block hasn't got enough free space to hold the requested size.
const usize offset = get_fair_offset_to_split_at(block, size + sizeof(HeapBlock));