Cleanup errors in sceHeapFreeHeapMemory().

This commit is contained in:
Unknown W. Brackets committed 2013-10-13 19:20:04 -07:00
1 parent df285cec64
commit 9388dd092f
1 file changed
+8 -5
+8 -5
View File
@@ -79,18 +79,21 @@ int sceHeapReallocHeapMemoryWithOption(u32 heapPtr, u32 memPtr, int memSize, u32
}
int sceHeapFreeHeapMemory(u32 heapAddr, u32 memAddr) {
if (!Memory::IsValidAddress(memAddr))
return SCE_KERNEL_ERROR_ILLEGAL_ADDR;
Heap *heap = getHeap(heapAddr);
if (!heap) {
ERROR_LOG(HLE, "sceHeapFreeHeapMemory(%08x, %08x): invalid heap", heapAddr, memAddr);
return SCE_KERNEL_ERROR_INVALID_ID;
}
if(!heap->alloc.FreeExact(memAddr))
return SCE_KERNEL_ERROR_INVALID_POINTER;
DEBUG_LOG(HLE, "sceHeapFreeHeapMemory(%08x, %08x)", heapAddr, memAddr);
// An invalid address will crash the PSP, but 0 is always returns success.
if (memAddr == 0) {
return 0;
}
DEBUG_LOG(HLE,"sceHeapFreeHeapMemory(%08x, %08x)", heapAddr, memAddr);
if (!heap->alloc.FreeExact(memAddr)) {
return SCE_KERNEL_ERROR_INVALID_POINTER;
}
return 0;
}