Heap: Avoid accessing a block after it's potentially deleted
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
parent
08d5d727ee
commit
4697a16206
@ -130,6 +130,8 @@ static Result<void> combine_forward(HeapBlock* block)
|
|||||||
heap.remove(next);
|
heap.remove(next);
|
||||||
next->magic = BLOCK_DEAD;
|
next->magic = BLOCK_DEAD;
|
||||||
|
|
||||||
|
block->full_size += next->full_size + sizeof(HeapBlock);
|
||||||
|
|
||||||
if (next->status & BLOCK_END_MEM)
|
if (next->status & BLOCK_END_MEM)
|
||||||
{
|
{
|
||||||
if (next->status & BLOCK_START_MEM)
|
if (next->status & BLOCK_START_MEM)
|
||||||
@ -142,8 +144,6 @@ static Result<void> combine_forward(HeapBlock* block)
|
|||||||
block->status |= BLOCK_END_MEM;
|
block->status |= BLOCK_END_MEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
block->full_size += next->full_size + sizeof(HeapBlock);
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +159,8 @@ static Result<HeapBlock*> combine_backward(HeapBlock* block)
|
|||||||
heap.remove(block);
|
heap.remove(block);
|
||||||
block->magic = BLOCK_DEAD;
|
block->magic = BLOCK_DEAD;
|
||||||
|
|
||||||
|
last->full_size += block->full_size + sizeof(HeapBlock);
|
||||||
|
|
||||||
if (block->status & BLOCK_END_MEM)
|
if (block->status & BLOCK_END_MEM)
|
||||||
{
|
{
|
||||||
if (block->status & BLOCK_START_MEM)
|
if (block->status & BLOCK_START_MEM)
|
||||||
@ -171,8 +173,6 @@ static Result<HeapBlock*> combine_backward(HeapBlock* block)
|
|||||||
last->status |= BLOCK_END_MEM;
|
last->status |= BLOCK_END_MEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
last->full_size += block->full_size + sizeof(HeapBlock);
|
|
||||||
|
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user