diff --git a/configuration.c b/configuration.c index 7eb979bc75..908cff9870 100644 --- a/configuration.c +++ b/configuration.c @@ -3781,8 +3781,11 @@ bool config_load_remap(const char *directory_input_remapping, /* If a game remap file exists, load it. */ 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); - if (input_remapping_load_file(new_conf, game_path)) + if (ret) { rarch_ctl(RARCH_CTL_SET_REMAPS_GAME_ACTIVE, NULL); /* 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 ((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); - if (input_remapping_load_file(new_conf, content_path)) + if (ret) { rarch_ctl(RARCH_CTL_SET_REMAPS_CONTENT_DIR_ACTIVE, NULL); 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 ((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); - if (input_remapping_load_file(new_conf, core_path)) + if (ret) { rarch_ctl(RARCH_CTL_SET_REMAPS_CORE_ACTIVE, NULL); 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; 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_file_free(conf); - return true; } diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 0d1bcc7284..2de5aa02c0 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1990,6 +1990,7 @@ static int generic_action_ok(const char *path, conf_key[0] = '\0'; if (conf) + { if (input_remapping_load_file(conf, action_path)) { 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); } } + config_file_free(conf); + conf = NULL; + } } #endif break;