Fix crash when freeing the last allocated bitmap
@@ -141,7 +141,7 @@ bool GraphicsMemoryHeap::Release(void *pHeapBlockData)
currentBlk->status = blockFree;
// If the next block is free, then subsume next block into current including data length and block header
- if (nextBlock->status == blockFree) // end block status is always heap_end
+ if ((nextBlock != NOT_APPLICABLE) && (nextBlock->status == blockFree)) // end block status is always heap_end
{
currentBlk->dataLength += nextBlock->dataLength + blockHeaderSize;
currentBlk->next = nextBlock->next;
@@ -149,7 +149,8 @@ bool GraphicsMemoryHeap::Release(void *pHeapBlockData)
}
// If the previous block is free, then subsume current block into previous including data length and block
// header
- if (prevBlock->status == blockFree && prevBlock != ptrfirstBlockHeader) // Guard against looking outside heap
+ if ((prevBlock != NOT_APPLICABLE) && (prevBlock->status == blockFree) &&
+ (prevBlock != ptrfirstBlockHeader)) // Guard against looking outside heap
{
prevBlock->dataLength += currentBlk->dataLength + blockHeaderSize;
prevBlock->next = currentBlk->next;
