Fix some Coverity errors

This commit is contained in:
twinaphex 2017-09-30 16:52:41 +02:00
parent 98ddc80035
commit 2a8b74eeb9
2 changed files with 27 additions and 9 deletions

View File

@ -1018,6 +1018,8 @@ static void xmb_update_thumbnail_path(void *data, unsigned i)
end:
menu_entry_free(&entry);
if (!string_is_empty(tmp))
free(tmp);
free(tmp_new);
}
@ -2315,8 +2317,20 @@ static int xmb_draw_item(
entry_type = menu_entry_get_type_new(entry);
if (entry_type == FILE_TYPE_CONTENTLIST_ENTRY)
fill_short_pathname_representation(entry->path, entry->path,
sizeof(entry->path));
{
char entry_path[PATH_MAX_LENGTH] = {0};
strlcpy(entry_path, entry->path, sizeof(entry_path));
fill_short_pathname_representation(entry_path, entry_path,
sizeof(entry_path));
if (!string_is_empty(entry_path))
{
if (!string_is_empty(entry->path))
free(entry->path);
entry->path = strdup(entry_path);
}
}
if (string_is_equal(entry->value, msg_hash_to_str(MENU_ENUM_LABEL_DISABLED)) ||
(string_is_equal(entry->value, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))))
@ -2522,7 +2536,7 @@ static void xmb_draw_items(
uint64_t frame_count = xmb ? xmb->frame_count : 0;
const char *thumb_ident = xmb_thumbnails_ident();
if (!list || !list->size)
if (!list || !list->size || !xmb)
return;
if (cat_selection_ptr > xmb->system_tab_end)

View File

@ -251,7 +251,10 @@ static bool input_autoconfigure_joypad_from_conf_dir(
if(!list)
return false;
RARCH_LOG("[Autoconf]: %d profiles found.\n", list->size);
if (list)
{
RARCH_LOG("[Autoconf]: %d profiles found.\n", list->size);
}
for (i = 0; i < list->size; i++)
{
@ -474,11 +477,12 @@ bool input_autoconfigure_connect(
{
unsigned i;
retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task));
autoconfig_params_t *state = (autoconfig_params_t*)malloc(sizeof(*state));
autoconfig_params_t *state = (autoconfig_params_t*)malloc(sizeof(autoconfig_params_t));
settings_t *settings = config_get_ptr();
const char *dir_autoconf = settings->paths.directory_autoconfig;
const char *dir_autoconf = settings ? settings->paths.directory_autoconfig : NULL;
bool autodetect_enable = settings ? settings->bools.input_autodetect_enable : false;
if (!task || !state || !settings->bools.input_autodetect_enable)
if (!task || !state || !autodetect_enable)
goto error;
state->name = NULL;
@ -517,8 +521,8 @@ bool input_autoconfigure_connect(
input_autoconfigured[state->idx] = false;
task->state = state;
task->handler = input_autoconfigure_connect_handler;
task->state = state;
task->handler = input_autoconfigure_connect_handler;
task_queue_push(task);