prevent null derefs found by scan-build

This commit is contained in:
Brad Parker 2019-04-18 11:46:53 -04:00
parent fa128f950d
commit e7dbac7eb0
7 changed files with 42 additions and 27 deletions

View File

@ -503,7 +503,8 @@ static const gfx_ctx_driver_t *gl_core_get_context(gl_core_t *gl)
#endif
/* Force shared context. */
gl->use_shared_context = hwr->context_type != RETRO_HW_CONTEXT_NONE;
if (hwr)
gl->use_shared_context = hwr->context_type != RETRO_HW_CONTEXT_NONE;
gfx_ctx = video_context_driver_init_first(gl,
settings->arrays.video_context_driver,

View File

@ -483,15 +483,18 @@ struct http_t *net_http_new(struct http_connection_t *conn)
return state;
error:
if (conn->methodcopy)
free(conn->methodcopy);
if (conn->contenttypecopy)
free(conn->contenttypecopy);
conn->methodcopy = NULL;
conn->contenttypecopy = NULL;
conn->postdatacopy = NULL;
if (conn)
{
if (conn->methodcopy)
free(conn->methodcopy);
if (conn->contenttypecopy)
free(conn->contenttypecopy);
conn->methodcopy = NULL;
conn->contenttypecopy = NULL;
conn->postdatacopy = NULL;
}
#ifdef HAVE_SSL
if (conn->sock_state.ssl && conn->sock_state.ssl_ctx && fd >= 0)
if (conn && conn->sock_state.ssl && conn->sock_state.ssl_ctx && fd >= 0)
{
ssl_socket_close(conn->sock_state.ssl_ctx);
ssl_socket_free(conn->sock_state.ssl_ctx);

View File

@ -418,8 +418,9 @@ static int general_push(menu_displaylist_info_t *info,
}
else
{
strlcpy(newstring2, system->valid_extensions,
PATH_MAX_LENGTH * sizeof(char));
if (system)
strlcpy(newstring2, system->valid_extensions,
PATH_MAX_LENGTH * sizeof(char));
}
}
break;
@ -442,7 +443,7 @@ static int general_push(menu_displaylist_info_t *info,
}
else
{
if (!string_is_empty(system->valid_extensions))
if (system && !string_is_empty(system->valid_extensions))
{
new_exts = strdup(system->valid_extensions);
new_exts_allocated = true;
@ -473,7 +474,12 @@ static int general_push(menu_displaylist_info_t *info,
}
if (new_exts_allocated)
{
free(new_exts);
if (new_exts == info->exts)
info->exts = NULL;
}
}
break;
case PUSH_ARCHIVE_OPEN_DETECT_CORE:

View File

@ -3611,7 +3611,7 @@ finish:
(transf ? transf->path: "unknown"), err);
}
#ifdef HAVE_DISCORD
else if (transf->enum_idx == MENU_ENUM_LABEL_CB_DISCORD_AVATAR)
else if (transf && transf->enum_idx == MENU_ENUM_LABEL_CB_DISCORD_AVATAR)
discord_avatar_set_ready(true);
#endif

View File

@ -301,19 +301,23 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
return menu;
error:
if (ozone->horizontal_list)
if (ozone)
{
ozone_free_list_nodes(ozone->horizontal_list, false);
file_list_free(ozone->horizontal_list);
}
if (ozone->horizontal_list)
{
ozone_free_list_nodes(ozone->horizontal_list, false);
file_list_free(ozone->horizontal_list);
}
if (ozone->selection_buf_old)
{
ozone_free_list_nodes(ozone->selection_buf_old, false);
file_list_free(ozone->selection_buf_old);
if (ozone->selection_buf_old)
{
ozone_free_list_nodes(ozone->selection_buf_old, false);
file_list_free(ozone->selection_buf_old);
}
ozone->selection_buf_old = NULL;
ozone->horizontal_list = NULL;
}
ozone->selection_buf_old = NULL;
ozone->horizontal_list = NULL;
if (menu)
free(menu);

View File

@ -441,7 +441,8 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info,
}
border_iterate:
y += node->height;
if (node)
y += node->height;
}
/* Cursor(s) layer - current */

View File

@ -2886,7 +2886,7 @@ static int menu_displaylist_parse_horizontal_content_actions(
{
const char *ext = NULL;
if (!string_is_empty(entry->path))
if (entry && !string_is_empty(entry->path))
ext = path_get_extension(entry->path);
if (!string_is_empty(ext) &&
@ -2943,7 +2943,7 @@ static int menu_displaylist_parse_horizontal_content_actions(
}
}
if (!string_is_empty(entry->db_name) && (!content_loaded ||
if ((entry && !string_is_empty(entry->db_name)) && (!content_loaded ||
(content_loaded && settings->bools.quick_menu_show_information)))
{
char *db_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
@ -7782,7 +7782,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
PARSE_ACTION, false);
/* Core fully loaded, use the subsystem data */
if (sys_info->subsystem.data)
if (sys_info && sys_info->subsystem.data)
subsystem = sys_info->subsystem.data;
/* Core not loaded completely, use the data we peeked on load core */
else