mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-23 19:30:45 +00:00
Prevent explicit null dereferenced warnings
This commit is contained in:
parent
a98616b45b
commit
03ded43280
24
command.c
24
command.c
@ -383,7 +383,7 @@ static bool command_verify(const char *cmd)
|
||||
|
||||
bool command_network_send(const char *cmd_)
|
||||
{
|
||||
bool ret;
|
||||
bool ret = false;
|
||||
char *command = NULL;
|
||||
char *save = NULL;
|
||||
const char *cmd = NULL;
|
||||
@ -415,11 +415,14 @@ bool command_network_send(const char *cmd_)
|
||||
if (port_)
|
||||
port = strtoul(port_, NULL, 0);
|
||||
|
||||
RARCH_LOG("%s: \"%s\" to %s:%hu\n",
|
||||
msg_hash_to_str(MSG_SENDING_COMMAND),
|
||||
cmd, host, (unsigned short)port);
|
||||
if (cmd)
|
||||
{
|
||||
RARCH_LOG("%s: \"%s\" to %s:%hu\n",
|
||||
msg_hash_to_str(MSG_SENDING_COMMAND),
|
||||
cmd, host, (unsigned short)port);
|
||||
|
||||
ret = command_verify(cmd) && send_udp_packet(host, port, cmd);
|
||||
ret = command_verify(cmd) && send_udp_packet(host, port, cmd);
|
||||
}
|
||||
free(command);
|
||||
|
||||
return ret;
|
||||
@ -1662,12 +1665,13 @@ bool command_event(enum event_command cmd, void *data)
|
||||
unsigned idx = 0;
|
||||
unsigned *window_scale = NULL;
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_GET_WINDOWED_SCALE, &window_scale);
|
||||
if (runloop_ctl(RUNLOOP_CTL_GET_WINDOWED_SCALE, &window_scale))
|
||||
{
|
||||
if (*window_scale == 0)
|
||||
return false;
|
||||
|
||||
if (*window_scale == 0)
|
||||
return false;
|
||||
|
||||
settings->video.scale = *window_scale;
|
||||
settings->video.scale = *window_scale;
|
||||
}
|
||||
|
||||
if (!settings->video.fullscreen)
|
||||
command_event(CMD_EVENT_REINIT, NULL);
|
||||
|
20
dynamic.c
20
dynamic.c
@ -824,16 +824,17 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
||||
if (string_is_empty(settings->directory.system))
|
||||
{
|
||||
char *fullpath = NULL;
|
||||
runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath);
|
||||
|
||||
RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR %s\n",
|
||||
fullpath);
|
||||
fill_pathname_basedir(global->dir.systemdir, fullpath,
|
||||
sizeof(global->dir.systemdir));
|
||||
if (runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath))
|
||||
{
|
||||
RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR %s\n",
|
||||
fullpath);
|
||||
fill_pathname_basedir(global->dir.systemdir, fullpath,
|
||||
sizeof(global->dir.systemdir));
|
||||
}
|
||||
|
||||
*(const char**)data = global->dir.systemdir;
|
||||
RARCH_LOG("Environ SYSTEM_DIRECTORY: \"%s\".\n",
|
||||
global->dir.systemdir);
|
||||
global->dir.systemdir);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -898,7 +899,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
||||
"L", "R", "L2", "R2", "L3", "R3",
|
||||
};
|
||||
|
||||
memset(system->input_desc_btn, 0,
|
||||
memset(&system->input_desc_btn, 0,
|
||||
sizeof(system->input_desc_btn));
|
||||
|
||||
desc = (const struct retro_input_descriptor*)data;
|
||||
@ -998,7 +999,8 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
||||
RARCH_LOG("Environ SET_KEYBOARD_CALLBACK.\n");
|
||||
if (key_event)
|
||||
*key_event = info->callback;
|
||||
if (frontend_key_event)
|
||||
|
||||
if (frontend_key_event && key_event)
|
||||
*frontend_key_event = *key_event;
|
||||
break;
|
||||
}
|
||||
|
@ -302,10 +302,10 @@ static bool parse_line(config_file_t *conf,
|
||||
struct config_entry_list *list, char *line)
|
||||
{
|
||||
char *comment = NULL;
|
||||
char *key = (char*)malloc(9);
|
||||
char *key_tmp = NULL;
|
||||
size_t cur_size = 8;
|
||||
size_t idx = 0;
|
||||
char *key = (char*)malloc(9);
|
||||
|
||||
if (!key)
|
||||
return false;
|
||||
|
@ -244,8 +244,11 @@ static void retro_task_regular_retrieve(task_retriever_data_t *data)
|
||||
}
|
||||
else
|
||||
{
|
||||
tail->next = info;
|
||||
tail = tail->next;
|
||||
if (tail)
|
||||
{
|
||||
tail->next = info;
|
||||
tail = tail->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -685,18 +685,19 @@ static int mui_get_core_title(char *s, size_t len)
|
||||
core_name = system->library_name;
|
||||
core_version = system->library_version;
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
|
||||
|
||||
if (!settings->menu.core_enable)
|
||||
return -1;
|
||||
|
||||
if (string_is_empty(core_name))
|
||||
core_name = info->info.library_name;
|
||||
if (string_is_empty(core_name))
|
||||
core_name = menu_hash_to_str(MENU_VALUE_NO_CORE);
|
||||
if (runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info))
|
||||
{
|
||||
if (string_is_empty(core_name))
|
||||
core_name = info->info.library_name;
|
||||
if (!core_version)
|
||||
core_version = info->info.library_version;
|
||||
}
|
||||
|
||||
if (!core_version)
|
||||
core_version = info->info.library_version;
|
||||
if (string_is_empty(core_name))
|
||||
core_name = menu_hash_to_str(MENU_VALUE_NO_CORE);
|
||||
if (!core_version)
|
||||
core_version = "";
|
||||
|
||||
|
@ -289,13 +289,14 @@ static bool menu_entries_elem_is_dir(file_list_t *list,
|
||||
static int menu_entries_elem_get_first_char(
|
||||
file_list_t *list, unsigned offset)
|
||||
{
|
||||
int ret;
|
||||
int ret = 0;
|
||||
const char *path = NULL;
|
||||
|
||||
menu_entries_get_at_offset(list, offset,
|
||||
NULL, NULL, NULL, NULL, &path);
|
||||
|
||||
ret = tolower((int)*path);
|
||||
if (path != NULL)
|
||||
ret = tolower((int)*path);
|
||||
|
||||
/* "Normalize" non-alphabetical entries so they
|
||||
* are lumped together for purposes of jumping. */
|
||||
|
@ -1081,12 +1081,9 @@ static int menu_input_pointer_post_iterate(
|
||||
int ret = 0;
|
||||
menu_input_t *menu_input = menu_input_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool check_overlay = false;
|
||||
|
||||
if (settings)
|
||||
check_overlay = !settings->menu.pointer.enable;
|
||||
bool check_overlay = settings ? !settings->menu.pointer.enable : false;
|
||||
|
||||
if (!menu_input)
|
||||
if (!menu_input || !settings)
|
||||
return -1;
|
||||
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
|
||||
return -1;
|
||||
|
@ -1065,22 +1065,23 @@ static void setting_get_string_representation_uint_libretro_device(void *data,
|
||||
unsigned index_offset;
|
||||
const struct retro_controller_description *desc = NULL;
|
||||
const char *name = NULL;
|
||||
rarch_system_info_t *system = NULL;
|
||||
rarch_setting_t *setting = (rarch_setting_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
rarch_system_info_t *system = NULL;
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
|
||||
|
||||
if (!setting)
|
||||
return;
|
||||
|
||||
index_offset = menu_setting_get_index_offset(setting);
|
||||
|
||||
if (index_offset < system->ports.size)
|
||||
desc = libretro_find_controller_description(
|
||||
&system->ports.data[index_offset],
|
||||
settings->input.libretro_device
|
||||
[index_offset]);
|
||||
if (runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system))
|
||||
{
|
||||
if (index_offset < system->ports.size)
|
||||
desc = libretro_find_controller_description(
|
||||
&system->ports.data[index_offset],
|
||||
settings->input.libretro_device
|
||||
[index_offset]);
|
||||
}
|
||||
|
||||
if (desc)
|
||||
name = desc->desc;
|
||||
@ -2346,11 +2347,9 @@ static int setting_action_start_libretro_device_type(void *data)
|
||||
unsigned index_offset, current_device;
|
||||
unsigned devices[128], types = 0, port = 0;
|
||||
const struct retro_controller_info *desc = NULL;
|
||||
rarch_setting_t *setting = (rarch_setting_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
rarch_system_info_t *system = NULL;
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
|
||||
settings_t *settings = config_get_ptr();
|
||||
rarch_setting_t *setting = (rarch_setting_t*)data;
|
||||
|
||||
if (setting_generic_action_start_default(setting) != 0)
|
||||
return -1;
|
||||
@ -2361,13 +2360,16 @@ static int setting_action_start_libretro_device_type(void *data)
|
||||
devices[types++] = RETRO_DEVICE_NONE;
|
||||
devices[types++] = RETRO_DEVICE_JOYPAD;
|
||||
|
||||
/* Only push RETRO_DEVICE_ANALOG as default if we use an
|
||||
* older core which doesn't use SET_CONTROLLER_INFO. */
|
||||
if (!system->ports.size)
|
||||
devices[types++] = RETRO_DEVICE_ANALOG;
|
||||
if (runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system))
|
||||
{
|
||||
/* Only push RETRO_DEVICE_ANALOG as default if we use an
|
||||
* older core which doesn't use SET_CONTROLLER_INFO. */
|
||||
if (!system->ports.size)
|
||||
devices[types++] = RETRO_DEVICE_ANALOG;
|
||||
|
||||
desc = port < system->ports.size ?
|
||||
&system->ports.data[port] : NULL;
|
||||
desc = port < system->ports.size ?
|
||||
&system->ports.data[port] : NULL;
|
||||
}
|
||||
|
||||
if (desc)
|
||||
{
|
||||
|
49
retroarch.c
49
retroarch.c
@ -1099,7 +1099,7 @@ static void retroarch_init_savefile_paths(void)
|
||||
global->savefiles = string_list_new();
|
||||
retro_assert(global->savefiles);
|
||||
|
||||
if (*global->subsystem)
|
||||
if (system && *global->subsystem)
|
||||
{
|
||||
/* For subsystems, we know exactly which RAM types are supported. */
|
||||
|
||||
@ -1317,35 +1317,36 @@ bool retroarch_main_init(int argc, char *argv[])
|
||||
settings->multimedia.builtin_imageviewer_enable))
|
||||
{
|
||||
char *fullpath = NULL;
|
||||
#if defined(HAVE_FFMPEG) || defined(HAVE_IMAGEVIEWER)
|
||||
global_t *global = global_get_ptr();
|
||||
#endif
|
||||
|
||||
runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath);
|
||||
|
||||
switch (retroarch_path_is_media_type(fullpath))
|
||||
if (runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath))
|
||||
{
|
||||
case RARCH_CONTENT_MOVIE:
|
||||
case RARCH_CONTENT_MUSIC:
|
||||
if (settings->multimedia.builtin_mediaplayer_enable)
|
||||
{
|
||||
#if defined(HAVE_FFMPEG) || defined(HAVE_IMAGEVIEWER)
|
||||
global_t *global = global_get_ptr();
|
||||
#endif
|
||||
switch (retroarch_path_is_media_type(fullpath))
|
||||
{
|
||||
case RARCH_CONTENT_MOVIE:
|
||||
case RARCH_CONTENT_MUSIC:
|
||||
if (settings->multimedia.builtin_mediaplayer_enable)
|
||||
{
|
||||
#ifdef HAVE_FFMPEG
|
||||
global->has_set.libretro = false;
|
||||
current_core_type = CORE_TYPE_FFMPEG;
|
||||
global->has_set.libretro = false;
|
||||
current_core_type = CORE_TYPE_FFMPEG;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_IMAGEVIEWER
|
||||
case RARCH_CONTENT_IMAGE:
|
||||
if (settings->multimedia.builtin_imageviewer_enable)
|
||||
{
|
||||
global->has_set.libretro = false;
|
||||
current_core_type = CORE_TYPE_IMAGEVIEWER;
|
||||
}
|
||||
break;
|
||||
case RARCH_CONTENT_IMAGE:
|
||||
if (settings->multimedia.builtin_imageviewer_enable)
|
||||
{
|
||||
global->has_set.libretro = false;
|
||||
current_core_type = CORE_TYPE_IMAGEVIEWER;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,9 +168,9 @@ static int content_7zip_file_read(
|
||||
{
|
||||
CFileInStream archiveStream;
|
||||
CLookToRead lookStream;
|
||||
CSzArEx db;
|
||||
ISzAlloc allocImp;
|
||||
ISzAlloc allocTempImp;
|
||||
CSzArEx db = {0};
|
||||
uint8_t *output = 0;
|
||||
long outsize = -1;
|
||||
|
||||
@ -232,8 +232,10 @@ static int content_7zip_file_read(
|
||||
}
|
||||
|
||||
SzArEx_GetFileNameUtf16(&db, i, temp);
|
||||
res = utf16_to_char_string(temp, infile, sizeof(infile))
|
||||
? SZ_OK : SZ_ERROR_FAIL;
|
||||
res = SZ_ERROR_FAIL;
|
||||
if (temp)
|
||||
res = utf16_to_char_string(temp, infile, sizeof(infile))
|
||||
? SZ_OK : SZ_ERROR_FAIL;
|
||||
|
||||
if (string_is_equal(infile, needle))
|
||||
{
|
||||
@ -309,9 +311,9 @@ static struct string_list *compressed_7zip_file_list_new(
|
||||
{
|
||||
CFileInStream archiveStream;
|
||||
CLookToRead lookStream;
|
||||
CSzArEx db;
|
||||
ISzAlloc allocImp;
|
||||
ISzAlloc allocTempImp;
|
||||
CSzArEx db = {0};
|
||||
size_t temp_size = 0;
|
||||
struct string_list *list = NULL;
|
||||
|
||||
@ -379,8 +381,12 @@ static struct string_list *compressed_7zip_file_list_new(
|
||||
}
|
||||
|
||||
SzArEx_GetFileNameUtf16(&db, i, temp);
|
||||
res = utf16_to_char_string(temp, infile, sizeof(infile))
|
||||
? SZ_OK : SZ_ERROR_FAIL;
|
||||
res = SZ_ERROR_FAIL;
|
||||
|
||||
if (temp)
|
||||
res = utf16_to_char_string(temp, infile, sizeof(infile))
|
||||
? SZ_OK : SZ_ERROR_FAIL;
|
||||
|
||||
file_ext = path_get_extension(infile);
|
||||
|
||||
if (string_list_find_elem_prefix(ext_list, ".", file_ext))
|
||||
@ -1364,9 +1370,8 @@ static bool init_content_file_set_attribs(
|
||||
else
|
||||
{
|
||||
char *fullpath = NULL;
|
||||
runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath);
|
||||
|
||||
string_list_append(content, fullpath, attr);
|
||||
if (runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath))
|
||||
string_list_append(content, fullpath, attr);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user