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: 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) 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"); RARCH_LOG("Environ SET_MEMORY_MAPS.\n");
free((void*)system->mmaps.descriptors); free((void*)system->mmaps.descriptors);
system->mmaps.num_descriptors = 0; system->mmaps.num_descriptors = 0;
@ -1385,12 +1385,6 @@ bool rarch_environment_cb(unsigned cmd, void *data)
mmaps->num_descriptors * sizeof(*system->mmaps.descriptors)); mmaps->num_descriptors * sizeof(*system->mmaps.descriptors));
system->mmaps.num_descriptors = mmaps->num_descriptors; system->mmaps.num_descriptors = mmaps->num_descriptors;
mmap_preprocess_descriptors(descriptors, mmaps->num_descriptors); mmap_preprocess_descriptors(descriptors, mmaps->num_descriptors);
}
else
{
RARCH_WARN("Environ SET_MEMORY_MAPS, but system pointer not initialized..\n");
}
if (sizeof(void *) == 8) if (sizeof(void *) == 8)
RARCH_LOG(" ndx flags ptr offset start select disconn len addrspace\n"); RARCH_LOG(" ndx flags ptr offset start select disconn len addrspace\n");
@ -1432,6 +1426,13 @@ bool rarch_environment_cb(unsigned cmd, void *data)
desc->select, desc->disconnect, desc->len, desc->select, desc->disconnect, desc->len,
desc->addrspace ? desc->addrspace : ""); desc->addrspace ? desc->addrspace : "");
} }
}
else
{
RARCH_WARN("Environ SET_MEMORY_MAPS, but system pointer not initialized..\n");
}
break; break;
} }

View File

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

View File

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