Make rarch_main_clear_state more resilient

This commit is contained in:
twinaphex 2014-09-30 18:54:02 +02:00
parent e6f3f82440
commit c5f1788b36

View File

@ -2527,20 +2527,37 @@ static void deinit_log_file(void)
void rarch_main_clear_state(void)
{
static bool inited = false;
unsigned i;
memset(&g_settings, 0, sizeof(g_settings));
deinit_log_file();
if (inited)
uninit_drivers();
/* XXX This memset is really dangerous.
*
* (a) it can leak memory because the pointers
* in g_extern aren't freed.
* (b) it can zero pointers that the rest of
* the code will look at.
*/
memset(&g_extern, 0, sizeof(g_extern));
if (inited)
init_drivers();
init_state();
for (i = 0; i < MAX_PLAYERS; i++)
g_settings.input.libretro_device[i] = RETRO_DEVICE_JOYPAD;
init_msg_queue();
inited = true;
}
#ifdef HAVE_ZLIB