mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 16:13:40 +00:00
Make rarch_main_clear_state more resilient
This commit is contained in:
parent
e6f3f82440
commit
c5f1788b36
17
retroarch.c
17
retroarch.c
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user