mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
Fix crash that could happen after loading a remap file manually -
config file was being freed at the end of input_remapping_load_file when the menu_cbs_ok.c function was still using it afterwards - move the config_file_free outside of the function and free manually afterwards when we're done
This commit is contained in:
parent
05a2623875
commit
aa0a9f18d5
@ -3781,8 +3781,11 @@ bool config_load_remap(const char *directory_input_remapping,
|
|||||||
/* If a game remap file exists, load it. */
|
/* If a game remap file exists, load it. */
|
||||||
if ((new_conf = config_file_new_from_path_to_string(game_path)))
|
if ((new_conf = config_file_new_from_path_to_string(game_path)))
|
||||||
{
|
{
|
||||||
|
bool ret = input_remapping_load_file(new_conf, game_path);
|
||||||
|
config_file_free(new_conf);
|
||||||
|
new_conf = NULL;
|
||||||
RARCH_LOG("[Remaps]: Game-specific remap found at \"%s\".\n", game_path);
|
RARCH_LOG("[Remaps]: Game-specific remap found at \"%s\".\n", game_path);
|
||||||
if (input_remapping_load_file(new_conf, game_path))
|
if (ret)
|
||||||
{
|
{
|
||||||
rarch_ctl(RARCH_CTL_SET_REMAPS_GAME_ACTIVE, NULL);
|
rarch_ctl(RARCH_CTL_SET_REMAPS_GAME_ACTIVE, NULL);
|
||||||
/* msg_remap_loaded is set to MSG_GAME_REMAP_FILE_LOADED
|
/* msg_remap_loaded is set to MSG_GAME_REMAP_FILE_LOADED
|
||||||
@ -3794,8 +3797,11 @@ bool config_load_remap(const char *directory_input_remapping,
|
|||||||
/* If a content-dir remap file exists, load it. */
|
/* If a content-dir remap file exists, load it. */
|
||||||
if ((new_conf = config_file_new_from_path_to_string(content_path)))
|
if ((new_conf = config_file_new_from_path_to_string(content_path)))
|
||||||
{
|
{
|
||||||
|
bool ret = input_remapping_load_file(new_conf, content_path);
|
||||||
|
config_file_free(new_conf);
|
||||||
|
new_conf = NULL;
|
||||||
RARCH_LOG("[Remaps]: Content-dir-specific remap found at \"%s\".\n", content_path);
|
RARCH_LOG("[Remaps]: Content-dir-specific remap found at \"%s\".\n", content_path);
|
||||||
if (input_remapping_load_file(new_conf, content_path))
|
if (ret)
|
||||||
{
|
{
|
||||||
rarch_ctl(RARCH_CTL_SET_REMAPS_CONTENT_DIR_ACTIVE, NULL);
|
rarch_ctl(RARCH_CTL_SET_REMAPS_CONTENT_DIR_ACTIVE, NULL);
|
||||||
msg_remap_loaded = MSG_DIRECTORY_REMAP_FILE_LOADED;
|
msg_remap_loaded = MSG_DIRECTORY_REMAP_FILE_LOADED;
|
||||||
@ -3806,8 +3812,11 @@ bool config_load_remap(const char *directory_input_remapping,
|
|||||||
/* If a core remap file exists, load it. */
|
/* If a core remap file exists, load it. */
|
||||||
if ((new_conf = config_file_new_from_path_to_string(core_path)))
|
if ((new_conf = config_file_new_from_path_to_string(core_path)))
|
||||||
{
|
{
|
||||||
|
bool ret = input_remapping_load_file(new_conf, core_path);
|
||||||
|
config_file_free(new_conf);
|
||||||
|
new_conf = NULL;
|
||||||
RARCH_LOG("[Remaps]: Core-specific remap found at \"%s\".\n", core_path);
|
RARCH_LOG("[Remaps]: Core-specific remap found at \"%s\".\n", core_path);
|
||||||
if (input_remapping_load_file(new_conf, core_path))
|
if (ret)
|
||||||
{
|
{
|
||||||
rarch_ctl(RARCH_CTL_SET_REMAPS_CORE_ACTIVE, NULL);
|
rarch_ctl(RARCH_CTL_SET_REMAPS_CORE_ACTIVE, NULL);
|
||||||
msg_remap_loaded = MSG_CORE_REMAP_FILE_LOADED;
|
msg_remap_loaded = MSG_CORE_REMAP_FILE_LOADED;
|
||||||
@ -3815,6 +3824,8 @@ bool config_load_remap(const char *directory_input_remapping,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (new_conf)
|
||||||
|
config_file_free(new_conf);
|
||||||
new_conf = NULL;
|
new_conf = NULL;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -4607,8 +4618,6 @@ bool input_remapping_load_file(void *data, const char *path)
|
|||||||
CONFIG_GET_INT_BASE(conf, settings, uints.input_libretro_device[i], s1);
|
CONFIG_GET_INT_BASE(conf, settings, uints.input_libretro_device[i], s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
config_file_free(conf);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1990,6 +1990,7 @@ static int generic_action_ok(const char *path,
|
|||||||
conf_key[0] = '\0';
|
conf_key[0] = '\0';
|
||||||
|
|
||||||
if (conf)
|
if (conf)
|
||||||
|
{
|
||||||
if (input_remapping_load_file(conf, action_path))
|
if (input_remapping_load_file(conf, action_path))
|
||||||
{
|
{
|
||||||
for (port = 0; port < MAX_USERS; port++)
|
for (port = 0; port < MAX_USERS; port++)
|
||||||
@ -2005,6 +2006,9 @@ static int generic_action_ok(const char *path,
|
|||||||
core_set_controller_port_device(&pad);
|
core_set_controller_port_device(&pad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
config_file_free(conf);
|
||||||
|
conf = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user