mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-13 13:28:49 +00:00
Prevent explicit NULL dereferenced warnings
This commit is contained in:
parent
bc3eb34da5
commit
5eb43846da
41
dynamic.c
41
dynamic.c
@ -1363,26 +1363,33 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
||||
case RETRO_ENVIRONMENT_SET_MEMORY_MAPS:
|
||||
{
|
||||
unsigned i;
|
||||
struct retro_memory_descriptor *descriptors;
|
||||
const struct retro_memory_map *mmaps =
|
||||
struct retro_memory_descriptor *descriptors = NULL;
|
||||
const struct retro_memory_map *mmaps =
|
||||
(const struct retro_memory_map*)data;
|
||||
|
||||
free((void*)system->mmaps.descriptors);
|
||||
system->mmaps.num_descriptors = 0;
|
||||
if (system)
|
||||
{
|
||||
RARCH_LOG("Environ SET_MEMORY_MAPS.\n");
|
||||
free((void*)system->mmaps.descriptors);
|
||||
system->mmaps.num_descriptors = 0;
|
||||
descriptors = (struct retro_memory_descriptor*)
|
||||
calloc(mmaps->num_descriptors,
|
||||
sizeof(*system->mmaps.descriptors));
|
||||
|
||||
if (!descriptors)
|
||||
return false;
|
||||
|
||||
system->mmaps.descriptors = descriptors;
|
||||
memcpy((void*)system->mmaps.descriptors, mmaps->descriptors,
|
||||
mmaps->num_descriptors * sizeof(*system->mmaps.descriptors));
|
||||
system->mmaps.num_descriptors = mmaps->num_descriptors;
|
||||
mmap_preprocess_descriptors(descriptors, mmaps->num_descriptors);
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_WARN("Environ SET_MEMORY_MAPS, but system pointer not initialized..\n");
|
||||
}
|
||||
|
||||
descriptors = (struct retro_memory_descriptor*)
|
||||
calloc(mmaps->num_descriptors, sizeof(*system->mmaps.descriptors));
|
||||
|
||||
if (!descriptors)
|
||||
return false;
|
||||
|
||||
system->mmaps.descriptors = descriptors;
|
||||
memcpy((void*)system->mmaps.descriptors, mmaps->descriptors,
|
||||
mmaps->num_descriptors * sizeof(*system->mmaps.descriptors));
|
||||
system->mmaps.num_descriptors = mmaps->num_descriptors;
|
||||
mmap_preprocess_descriptors(descriptors, mmaps->num_descriptors);
|
||||
|
||||
RARCH_LOG("Environ SET_MEMORY_MAPS.\n");
|
||||
|
||||
if (sizeof(void *) == 8)
|
||||
RARCH_LOG(" ndx flags ptr offset start select disconn len addrspace\n");
|
||||
|
@ -133,7 +133,7 @@ static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x)
|
||||
|
||||
x11_colormap_destroy();
|
||||
|
||||
if (x->g_should_reset_mode)
|
||||
if (x->g_should_reset_mode && g_x11_dpy)
|
||||
{
|
||||
x11_exit_fullscreen(g_x11_dpy, &x->g_desktop_mode);
|
||||
x->g_should_reset_mode = false;
|
||||
|
@ -451,7 +451,7 @@ static int file_archive_decompress_data_to_file(
|
||||
}
|
||||
|
||||
end:
|
||||
if (handle->data)
|
||||
if (handle && handle->data)
|
||||
free(handle->data);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user