Fix explicit NULL dereferenced/dereference before null check warnings

This commit is contained in:
twinaphex 2016-05-26 17:47:21 +02:00
parent 142dd82067
commit a98616b45b
12 changed files with 25 additions and 37 deletions

View File

@ -83,7 +83,7 @@ static void core_info_list_resolve_all_firmware(
core_info_t *info = (core_info_t*)&core_info_list->list[i]; core_info_t *info = (core_info_t*)&core_info_list->list[i];
config_file_t *config = (config_file_t*)info->config_data; config_file_t *config = (config_file_t*)info->config_data;
if (!info || !config) if (!config)
continue; continue;
if (!config_get_uint(config, "firmware_count", &count)) if (!config_get_uint(config, "firmware_count", &count))

View File

@ -833,9 +833,7 @@ static void check_proc_acpi_sysfs_ac_adapter(const char * node, bool *have_ac)
if (strstr((char*)buf, "1")) if (strstr((char*)buf, "1"))
*have_ac = true; *have_ac = true;
if (buf) free(buf);
free(buf);
buf = NULL;
} }
static bool next_string(char **_ptr, char **_str) static bool next_string(char **_ptr, char **_str)

View File

@ -348,7 +348,7 @@ static bool video_thread_handle_packet(
* it's called in this "special" way. */ * it's called in this "special" way. */
thr->frame.within_thread = true; thr->frame.within_thread = true;
if (thr->driver && thr->driver->read_viewport) if (thr->driver->read_viewport)
ret = thr->driver->read_viewport(thr->driver_data, ret = thr->driver->read_viewport(thr->driver_data,
(uint8_t*)pkt.data.v); (uint8_t*)pkt.data.v);

View File

@ -515,8 +515,7 @@ static void libusb_hid_free(void *data)
libusb_hotplug_deregister_callback(hid->ctx, hid->hp); libusb_hotplug_deregister_callback(hid->ctx, hid->hp);
libusb_exit(hid->ctx); libusb_exit(hid->ctx);
if (hid) free(hid);
free(hid);
} }
static void poll_thread(void *data) static void poll_thread(void *data)

View File

@ -59,11 +59,13 @@ ssem_t *ssem_new(int value)
return semaphore; return semaphore;
error: error:
if (semaphore->mutex)
slock_free(semaphore->mutex);
semaphore->mutex = NULL;
if (semaphore) if (semaphore)
{
if (semaphore->mutex)
slock_free(semaphore->mutex);
semaphore->mutex = NULL;
free((void*)semaphore); free((void*)semaphore);
}
return NULL; return NULL;
} }

View File

@ -200,14 +200,13 @@ static int deferred_push_cursor_manager_list_deferred_query_subsearch(
goto end; goto end;
strlcpy(info->path, str_list->elems[1].data, sizeof(info->path)); strlcpy(info->path, str_list->elems[1].data, sizeof(info->path));
strlcpy(info->path_b, str_list->elems[0].data, sizeof(info->path_b)); strlcpy(info->path_b, str_list->elems[0].data, sizeof(info->path_b));
strlcpy(info->path_c, query, sizeof(info->path_c)); strlcpy(info->path_c, query, sizeof(info->path_c));
ret = deferred_push_dlist(info, DISPLAYLIST_DATABASE_QUERY); ret = deferred_push_dlist(info, DISPLAYLIST_DATABASE_QUERY);
end: end:
if (str_list) string_list_free(str_list);
string_list_free(str_list);
#endif #endif
return ret; return ret;
} }

View File

@ -403,9 +403,6 @@ static bool zarch_zui_tab(zui_t *zui, struct zui_tabbed *tab,
const float *bg = zui_bg_panel; const float *bg = zui_bg_panel;
bool selected = tab->tab_selection == tab_id; /* TODO/FIXME */ bool selected = tab->tab_selection == tab_id; /* TODO/FIXME */
if (!zui || !tab )
return false;
if (!width) if (!width)
{ {
if (!zui->fb_buf) if (!zui->fb_buf)
@ -739,9 +736,6 @@ static int zarch_zui_render_lay_root(zui_t *zui)
tabbed.width = zui->width - 290 - 40; tabbed.width = zui->width - 290 - 40;
zui->next_selection_set = false; zui->next_selection_set = false;
if (!zui)
return 1;
if (zarch_zui_render_lay_root_recent(zui, &tabbed)) if (zarch_zui_render_lay_root_recent(zui, &tabbed))
return 0; return 0;
if (zarch_zui_render_lay_root_load (zui, &tabbed)) if (zarch_zui_render_lay_root_load (zui, &tabbed))

View File

@ -50,8 +50,7 @@ static void menu_list_free_list(file_list_t *list)
menu_driver_ctl(RARCH_MENU_CTL_LIST_FREE, &list_info); menu_driver_ctl(RARCH_MENU_CTL_LIST_FREE, &list_info);
} }
if (list) file_list_free(list);
file_list_free(list);
} }
static void menu_list_free(menu_list_t *menu_list) static void menu_list_free(menu_list_t *menu_list)

View File

@ -195,7 +195,8 @@ void menu_input_st_hex_cb(void *userdata, const char *str)
unsigned *ptr = (unsigned*)setting_get_ptr(setting); unsigned *ptr = (unsigned*)setting_get_ptr(setting);
if (str[0] == '#') if (str[0] == '#')
str++; str++;
*ptr = strtoul(str, NULL, 16); if (ptr)
*ptr = strtoul(str, NULL, 16);
} }
} }

View File

@ -411,8 +411,7 @@ static int task_database_iterate_crc_lookup(
if (db_state->list_index < db_state->list->size) if (db_state->list_index < db_state->list->size)
return 1; return 1;
if (db_state->info) database_info_list_free(db_state->info);
database_info_list_free(db_state->info);
return 0; return 0;
} }
@ -488,8 +487,7 @@ static int task_database_iterate_serial_lookup(
if (db_state->list_index < db_state->list->size) if (db_state->list_index < db_state->list->size)
return 1; return 1;
if (db_state->info) database_info_list_free(db_state->info);
database_info_list_free(db_state->info);
return 0; return 0;
} }

View File

@ -68,7 +68,7 @@ static int cb_image_menu_upload_generic(void *data, size_t len)
nbio_handle_t *nbio = (nbio_handle_t*)data; nbio_handle_t *nbio = (nbio_handle_t*)data;
nbio_image_handle_t *image = (nbio_image_handle_t*)nbio->data; nbio_image_handle_t *image = (nbio_image_handle_t*)nbio->data;
if (!nbio || !image) if (!image)
return -1; return -1;
if (image->processing_final_state == IMAGE_PROCESS_ERROR || if (image->processing_final_state == IMAGE_PROCESS_ERROR ||
@ -125,11 +125,11 @@ static int task_image_process(
static int cb_image_menu_generic(nbio_handle_t *nbio) static int cb_image_menu_generic(nbio_handle_t *nbio)
{ {
int retval;
unsigned width = 0, height = 0; unsigned width = 0, height = 0;
nbio_image_handle_t *image = (nbio_image_handle_t*)nbio->data; nbio_image_handle_t *image = (nbio_image_handle_t*)nbio->data;
int retval;
if (!nbio || !image) if (!image)
return -1; return -1;
retval = task_image_process(nbio, &width, &height); retval = task_image_process(nbio, &width, &height);
@ -157,11 +157,11 @@ static int cb_image_menu_thumbnail(void *data, size_t len)
static int task_image_iterate_process_transfer(nbio_handle_t *nbio) static int task_image_iterate_process_transfer(nbio_handle_t *nbio)
{ {
unsigned i, width = 0, height = 0;
int retval = 0; int retval = 0;
unsigned i, width = 0, height = 0;
nbio_image_handle_t *image = (nbio_image_handle_t*)nbio->data; nbio_image_handle_t *image = (nbio_image_handle_t*)nbio->data;
if (!nbio || !image) if (!image)
return -1; return -1;
for (i = 0; i < image->processing_pos_increment; i++) for (i = 0; i < image->processing_pos_increment; i++)
@ -184,7 +184,7 @@ static int task_image_iterate_transfer(nbio_handle_t *nbio)
unsigned i; unsigned i;
nbio_image_handle_t *image = (nbio_image_handle_t*)nbio->data; nbio_image_handle_t *image = (nbio_image_handle_t*)nbio->data;
if (!nbio || !image) if (!image)
goto error; goto error;
if (image->is_finished) if (image->is_finished)

View File

@ -101,7 +101,6 @@ static bool rarch_task_overlay_load_desc(
char conf_key[64] = {0}; char conf_key[64] = {0};
char overlay_desc_normalized_key[64] = {0}; char overlay_desc_normalized_key[64] = {0};
char overlay[256] = {0}; char overlay[256] = {0};
char *save = NULL;
char *key = NULL; char *key = NULL;
struct string_list *list = NULL; struct string_list *list = NULL;
const char *x = NULL; const char *x = NULL;
@ -174,12 +173,11 @@ static bool rarch_task_overlay_load_desc(
} }
else else
{ {
const char *tmp = NULL; char *save = NULL;
const char *tmp = strtok_r(key, "|", &save);
desc->type = OVERLAY_TYPE_BUTTONS; desc->type = OVERLAY_TYPE_BUTTONS;
tmp = strtok_r(key, "|", &save);
for (; tmp; tmp = strtok_r(NULL, "|", &save)) for (; tmp; tmp = strtok_r(NULL, "|", &save))
{ {
if (!string_is_equal(tmp, "nul")) if (!string_is_equal(tmp, "nul"))