From 093f16dd71c934a2f564e16f8733caad3642bbd8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 28 Sep 2016 08:08:35 +0200 Subject: [PATCH] Prevent NULL pointer dereference --- runloop.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/runloop.c b/runloop.c index 178d0e9c61..5a5fd5456b 100644 --- a/runloop.c +++ b/runloop.c @@ -920,21 +920,12 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) break; case RUNLOOP_CTL_CORE_OPTIONS_INIT: { + settings_t *settings = config_get_ptr(); char *game_options_path = NULL; bool ret = false; - char buf[PATH_MAX_LENGTH] = {0}; - settings_t *settings = config_get_ptr(); - const char *options_path = settings ? settings->path.core_options : NULL; const struct retro_variable *vars = (const struct retro_variable*)data; - if (string_is_empty(options_path) && !path_is_config_empty()) - { - fill_pathname_resolve_relative(buf, path_get_config(), - file_path_str(FILE_PATH_CORE_OPTIONS_CONFIG), sizeof(buf)); - options_path = buf; - } - if (settings && settings->game_specific_options) ret = rarch_game_specific_options(&game_options_path); @@ -947,6 +938,19 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) } else { + char buf[PATH_MAX_LENGTH] = {0}; + const char *options_path = NULL; + + if (settings) + options_path = settings->path.core_options; + + if (options_path && string_is_empty(options_path) && !path_is_config_empty()) + { + fill_pathname_resolve_relative(buf, path_get_config(), + file_path_str(FILE_PATH_CORE_OPTIONS_CONFIG), sizeof(buf)); + options_path = buf; + } + runloop_ctl(RUNLOOP_CTL_UNSET_GAME_OPTIONS_ACTIVE, NULL); runloop_core_options = core_option_manager_new(options_path, vars);