plugged a bunch of handle leaks !
This commit is contained in:
parent
08f8caf924
commit
58a1f0c68e
@ -22,6 +22,8 @@ extern char* fake_heap_end;
|
||||
static void initArgv();
|
||||
static u32 heapBase;
|
||||
|
||||
void __destroy_handle_list(void);
|
||||
|
||||
void __attribute__((noreturn)) __ctru_exit(int rc)
|
||||
{
|
||||
// Run the global destructors
|
||||
@ -35,6 +37,9 @@ void __attribute__((noreturn)) __ctru_exit(int rc)
|
||||
// Unmap the application heap
|
||||
svcControlMemory(&heapBase, heapBase, 0x0, __heap_size, MEMOP_FREE, 0x0);
|
||||
|
||||
// Close some handles
|
||||
__destroy_handle_list();
|
||||
|
||||
// Jump to the loader if it provided a callback
|
||||
if (__system_retAddr)
|
||||
__system_retAddr();
|
||||
|
@ -360,7 +360,7 @@ void aptExit()
|
||||
svcCloseHandle(aptSleepSync);
|
||||
|
||||
svcCloseHandle(aptStatusMutex);
|
||||
//svcCloseHandle(aptLockHandle);
|
||||
svcCloseHandle(aptLockHandle);
|
||||
svcCloseHandle(aptStatusEvent);
|
||||
}
|
||||
|
||||
|
@ -788,7 +788,10 @@ FSFILE_Close(Handle handle)
|
||||
if((ret = svcSendSyncRequest(handle)))
|
||||
return ret;
|
||||
|
||||
return cmdbuf[1];
|
||||
ret = cmdbuf[1];
|
||||
if(!ret)ret = svcCloseHandle(handle);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*! Read data from an open file
|
||||
|
@ -59,6 +59,7 @@ void gspExitEventHandler()
|
||||
// Stop event thread
|
||||
gspRunEvents = false;
|
||||
svcWaitSynchronization(gspEventThread, 1000000000);
|
||||
svcCloseHandle(gspEventThread);
|
||||
|
||||
// Free events
|
||||
int i;
|
||||
|
@ -48,6 +48,7 @@ cleanup1:
|
||||
void hidExit()
|
||||
{
|
||||
// Unmap HID sharedmem and close handles.
|
||||
int i; for(i=0; i<5; i++)svcCloseHandle(hidEvents[i]);
|
||||
svcUnmapMemoryBlock(hidMemHandle, (u32)hidSharedMem);
|
||||
svcCloseHandle(hidMemHandle);
|
||||
svcCloseHandle(hidHandle);
|
||||
|
@ -45,6 +45,7 @@ cleanup1:
|
||||
void irrstExit()
|
||||
{
|
||||
irrstUsed = false;
|
||||
svcCloseHandle(irrstEvent);
|
||||
// Unmap ir:rst sharedmem and close handles.
|
||||
svcUnmapMemoryBlock(irrstMemHandle, (u32)irrstSharedMem);
|
||||
svcCloseHandle(irrstMemHandle);
|
||||
|
@ -58,6 +58,18 @@ Handle __get_handle_from_list(const char* name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __destroy_handle_list(void) {
|
||||
if((u32)__service_ptr == 0)
|
||||
return;
|
||||
|
||||
u32 i, num = __service_ptr->num;
|
||||
|
||||
for(i=0; i<num; i++)
|
||||
svcCloseHandle(__service_ptr->services[i].handle);
|
||||
|
||||
__service_ptr->num = 0;
|
||||
}
|
||||
|
||||
Result srvInit()
|
||||
{
|
||||
Result rc = 0;
|
||||
@ -163,4 +175,4 @@ Result srvUnregisterProcess(u32 procid)
|
||||
if((rc = svcSendSyncRequest(g_srv_handle))) return rc;
|
||||
|
||||
return cmdbuf[1];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user