Only call socExit() if socInit() succeeded

This commit is contained in:
Michael Theall 2016-04-09 11:54:34 -05:00
parent 56b509e58e
commit c7cd0ec231

View File

@ -1567,6 +1567,7 @@ ftp_init(void)
#ifdef _3DS #ifdef _3DS
soc_fail: soc_fail:
free(SOCU_buffer); free(SOCU_buffer);
SOCU_buffer = NULL;
memalign_fail: memalign_fail:
#ifdef ENABLE_LOGGING #ifdef ENABLE_LOGGING
@ -1577,7 +1578,6 @@ ftruncate_fail:
log_fail: log_fail:
#endif #endif
return -1; return -1;
#endif #endif
} }
@ -1601,10 +1601,14 @@ ftp_exit(void)
/* deinitialize SOC service */ /* deinitialize SOC service */
console_render(); console_render();
console_print(CYAN "Waiting for socExit()...\n" RESET); console_print(CYAN "Waiting for socExit()...\n" RESET);
ret = socExit();
if(ret != 0) if(SOCU_buffer != NULL)
console_print(RED "socExit: 0x%08X\n" RESET, (unsigned int)ret); {
free(SOCU_buffer); ret = socExit();
if(ret != 0)
console_print(RED "socExit: 0x%08X\n" RESET, (unsigned int)ret);
free(SOCU_buffer);
}
#ifdef ENABLE_LOGGING #ifdef ENABLE_LOGGING
/* close log file */ /* close log file */