mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-25 20:32:22 +00:00
Merge pull request #2422 from fr500/master
check for NULL pointer dereferences and make the code easier to read for remaps and overrides
This commit is contained in:
commit
5c21927430
@ -1859,20 +1859,28 @@ bool config_load_override(void)
|
||||
bool should_append = false;
|
||||
global_t *global = global_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
rarch_system_info_t *info = rarch_system_info_get_ptr();
|
||||
rarch_system_info_t *system = rarch_system_info_get_ptr();
|
||||
|
||||
if (!global || !settings || !info)
|
||||
if (!global || !settings || !system)
|
||||
{
|
||||
RARCH_ERR("Couldn't load override config file.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Early return in case a library isn't loaded */
|
||||
if (!info->info.library_name[0] != '\0' || !strcmp(info->info.library_name,"No Core"))
|
||||
if (!system->info.library_name[0] != '\0' || !strcmp(system->info.library_name,"No Core"))
|
||||
return false;
|
||||
|
||||
RARCH_LOG("Overrides: core name: %s\n", info->info.library_name);
|
||||
RARCH_LOG("Overrides: game name: %s\n", global->name.base);
|
||||
core_name = system ? system->info.library_name : NULL;
|
||||
game_name = global ? path_basename(global->name.base) : NULL;
|
||||
|
||||
if (!core_name || !game_name)
|
||||
return false;
|
||||
if (core_name[0] == '\0' || game_name == '\0')
|
||||
return false;
|
||||
|
||||
RARCH_LOG("Overrides: core name: %s\n", core_name);
|
||||
RARCH_LOG("Overrides: game name: %s\n", game_name);
|
||||
|
||||
/* Config directory: config_directory.
|
||||
* Try config directory setting first,
|
||||
@ -1889,9 +1897,6 @@ bool config_load_override(void)
|
||||
|
||||
RARCH_LOG("Overrides: config directory: %s\n", config_directory);
|
||||
|
||||
core_name = info->info.library_name;
|
||||
game_name = path_basename(global->name.base);
|
||||
|
||||
/* Concatenate strings into full paths for core_path, game_path */
|
||||
fill_pathname_join(core_path, config_directory, core_name, PATH_MAX_LENGTH);
|
||||
fill_pathname_join(core_path, core_path, core_name, PATH_MAX_LENGTH);
|
||||
@ -2046,14 +2051,22 @@ bool config_load_remap(void)
|
||||
char game_path[PATH_MAX_LENGTH] = {0}; /* final path for game-specific configuration (prefix+suffix) */
|
||||
global_t *global = global_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
rarch_system_info_t *info = rarch_system_info_get_ptr();
|
||||
rarch_system_info_t *system = rarch_system_info_get_ptr();
|
||||
|
||||
/* Early return in case a library isn't loaded or remapping is disabled */
|
||||
if (!info->info.library_name || !strcmp(info->info.library_name,"No Core"))
|
||||
if (!system->info.library_name || !strcmp(system->info.library_name,"No Core"))
|
||||
return false;
|
||||
|
||||
RARCH_LOG("Remaps: core name: %s\n", info->info.library_name);
|
||||
RARCH_LOG("Remaps: game name: %s\n", global->name.base);
|
||||
core_name = system ? system->info.library_name : NULL;
|
||||
game_name = global ? path_basename(global->name.base) : NULL;
|
||||
|
||||
if (!core_name || !game_name)
|
||||
return false;
|
||||
if (core_name[0] == '\0' || game_name == '\0')
|
||||
return false;
|
||||
|
||||
RARCH_LOG("Remaps: core name: %s\n", core_name);
|
||||
RARCH_LOG("Remaps: game name: %s\n", game_name);
|
||||
|
||||
/* Remap directory: remap_directory.
|
||||
* Try remap directory setting, no fallbacks defined */
|
||||
@ -2066,9 +2079,6 @@ bool config_load_remap(void)
|
||||
}
|
||||
RARCH_LOG("Remaps: remap directory: %s\n", remap_directory);
|
||||
|
||||
core_name = info->info.library_name;
|
||||
game_name = path_basename(global->name.base);
|
||||
|
||||
/* Concatenate strings into full paths for core_path, game_path */
|
||||
fill_pathname_join(core_path, remap_directory, core_name, PATH_MAX_LENGTH);
|
||||
fill_pathname_join(core_path, core_path, core_name, PATH_MAX_LENGTH);
|
||||
|
@ -1246,10 +1246,10 @@ static int action_ok_disk_cycle_tray_status(const char *path,
|
||||
return generic_action_ok_command(EVENT_CMD_DISK_EJECT_TOGGLE);
|
||||
}
|
||||
|
||||
/* creates folder and core options stub file for subsequent runs */
|
||||
static int action_ok_option_create(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
/* create folder and core options stub file for subsequent runs */
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
rarch_system_info_t *system = rarch_system_info_get_ptr();
|
||||
@ -1273,8 +1273,13 @@ static int action_ok_option_create(const char *path,
|
||||
return false;
|
||||
}
|
||||
|
||||
core_name = system->info.library_name;
|
||||
game_name = path_basename(global->name.base);
|
||||
core_name = system ? system->info.library_name : NULL;
|
||||
game_name = global ? path_basename(global->name.base) : NULL;
|
||||
|
||||
if (!core_name || !game_name)
|
||||
return false;
|
||||
if (core_name[0] == '\0' || game_name == '\0')
|
||||
return false;
|
||||
|
||||
/* Concatenate strings into full paths for game_path */
|
||||
fill_pathname_join(core_path, config_directory, core_name, PATH_MAX_LENGTH);
|
||||
|
Loading…
x
Reference in New Issue
Block a user