Fix some dereference after null check warnings

This commit is contained in:
twinaphex 2016-06-02 20:40:39 +02:00
parent 3d338446f8
commit 65d5ebc2bb
3 changed files with 58 additions and 50 deletions

View File

@ -1363,13 +1363,13 @@ bool rarch_environment_cb(unsigned cmd, void *data)
case RETRO_ENVIRONMENT_SET_MEMORY_MAPS:
{
unsigned i;
struct retro_memory_descriptor *descriptors = NULL;
const struct retro_memory_map *mmaps =
(const struct retro_memory_map*)data;
if (system)
{
unsigned i;
const struct retro_memory_map *mmaps =
(const struct retro_memory_map*)data;
struct retro_memory_descriptor *descriptors = NULL;
RARCH_LOG("Environ SET_MEMORY_MAPS.\n");
free((void*)system->mmaps.descriptors);
system->mmaps.num_descriptors = 0;
@ -1385,6 +1385,47 @@ bool rarch_environment_cb(unsigned cmd, void *data)
mmaps->num_descriptors * sizeof(*system->mmaps.descriptors));
system->mmaps.num_descriptors = mmaps->num_descriptors;
mmap_preprocess_descriptors(descriptors, mmaps->num_descriptors);
if (sizeof(void *) == 8)
RARCH_LOG(" ndx flags ptr offset start select disconn len addrspace\n");
else
RARCH_LOG(" ndx flags ptr offset start select disconn len addrspace\n");
for (i = 0; i < system->mmaps.num_descriptors; i++)
{
const struct retro_memory_descriptor *desc =
&system->mmaps.descriptors[i];
char flags[7];
flags[0] = 'M';
if ((desc->flags & RETRO_MEMDESC_MINSIZE_8) == RETRO_MEMDESC_MINSIZE_8)
flags[1] = '8';
else if ((desc->flags & RETRO_MEMDESC_MINSIZE_4) == RETRO_MEMDESC_MINSIZE_4)
flags[1] = '4';
else if ((desc->flags & RETRO_MEMDESC_MINSIZE_2) == RETRO_MEMDESC_MINSIZE_2)
flags[1] = '2';
else
flags[1] = '1';
flags[2] = 'A';
if ((desc->flags & RETRO_MEMDESC_ALIGN_8) == RETRO_MEMDESC_ALIGN_8)
flags[3] = '8';
else if ((desc->flags & RETRO_MEMDESC_ALIGN_4) == RETRO_MEMDESC_ALIGN_4)
flags[3] = '4';
else if ((desc->flags & RETRO_MEMDESC_ALIGN_2) == RETRO_MEMDESC_ALIGN_2)
flags[3] = '2';
else
flags[3] = '1';
flags[4] = (desc->flags & RETRO_MEMDESC_BIGENDIAN) ? 'B' : 'b';
flags[5] = (desc->flags & RETRO_MEMDESC_CONST) ? 'C' : 'c';
flags[6] = 0;
RARCH_LOG(" %03u %s %p %08X %08X %08X %08X %08X %s\n",
i + 1, flags, desc->ptr, desc->offset, desc->start,
desc->select, desc->disconnect, desc->len,
desc->addrspace ? desc->addrspace : "");
}
}
else
{
@ -1392,46 +1433,6 @@ bool rarch_environment_cb(unsigned cmd, void *data)
}
if (sizeof(void *) == 8)
RARCH_LOG(" ndx flags ptr offset start select disconn len addrspace\n");
else
RARCH_LOG(" ndx flags ptr offset start select disconn len addrspace\n");
for (i = 0; i < system->mmaps.num_descriptors; i++)
{
const struct retro_memory_descriptor *desc =
&system->mmaps.descriptors[i];
char flags[7];
flags[0] = 'M';
if ((desc->flags & RETRO_MEMDESC_MINSIZE_8) == RETRO_MEMDESC_MINSIZE_8)
flags[1] = '8';
else if ((desc->flags & RETRO_MEMDESC_MINSIZE_4) == RETRO_MEMDESC_MINSIZE_4)
flags[1] = '4';
else if ((desc->flags & RETRO_MEMDESC_MINSIZE_2) == RETRO_MEMDESC_MINSIZE_2)
flags[1] = '2';
else
flags[1] = '1';
flags[2] = 'A';
if ((desc->flags & RETRO_MEMDESC_ALIGN_8) == RETRO_MEMDESC_ALIGN_8)
flags[3] = '8';
else if ((desc->flags & RETRO_MEMDESC_ALIGN_4) == RETRO_MEMDESC_ALIGN_4)
flags[3] = '4';
else if ((desc->flags & RETRO_MEMDESC_ALIGN_2) == RETRO_MEMDESC_ALIGN_2)
flags[3] = '2';
else
flags[3] = '1';
flags[4] = (desc->flags & RETRO_MEMDESC_BIGENDIAN) ? 'B' : 'b';
flags[5] = (desc->flags & RETRO_MEMDESC_CONST) ? 'C' : 'c';
flags[6] = 0;
RARCH_LOG(" %03u %s %p %08X %08X %08X %08X %08X %s\n",
i + 1, flags, desc->ptr, desc->offset, desc->start,
desc->select, desc->disconnect, desc->len,
desc->addrspace ? desc->addrspace : "");
}
break;
}

View File

@ -171,7 +171,8 @@ error:
if (font_data)
free(font_data);
font_renderer_stb_free(self);
if (self)
font_renderer_stb_free(self);
return NULL;
}

View File

@ -404,8 +404,11 @@ static int task_database_iterate_crc_lookup(
db_state->entry_index++;
if (db_state->entry_index >= db_state->info->count)
return database_info_list_iterate_next(db_state);
if (db_state->info)
{
if (db_state->entry_index >= db_state->info->count)
return database_info_list_iterate_next(db_state);
}
/* If we haven't reached the end of the database list yet,
* continue iterating. */
@ -480,8 +483,11 @@ static int task_database_iterate_serial_lookup(
db_state->entry_index++;
if (db_state->entry_index >= db_state->info->count)
return database_info_list_iterate_next(db_state);
if (db_state->info)
{
if (db_state->entry_index >= db_state->info->count)
return database_info_list_iterate_next(db_state);
}
/* If we haven't reached the end of the database list yet,
* continue iterating. */