ios/kernel: Check block state in IOS_HeapRealloc

This commit is contained in:
GaryOderNichts 2023-10-20 12:30:19 +02:00 committed by James
parent d985cc8b2b
commit a0f9d66703

View file

@ -449,6 +449,11 @@ IOS_HeapRealloc(HeapId heapId,
}
auto block = phys_cast<HeapBlock *>(phys_cast<uint8_t *>(ptr) - sizeof(HeapBlock));
if (block->state != HeapBlockState::Allocated && block->state != HeapBlockState::InnerBlock) {
heap->errorCountExpandInvalidBlock++;
return nullptr;
}
auto blockSize = block->size;
size = align_up(size, HeapAllocSizeAlign);