Prevent more null pointer dereferences

This commit is contained in:
twinaphex 2016-06-30 17:40:19 +02:00
parent 01ab13f62c
commit 82a77279f3
1 changed files with 26 additions and 17 deletions

View File

@ -845,6 +845,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
if (!settings->video.allow_rotate)
break;
if (system)
system->rotation = rotation;
if (!video_driver_set_rotation(rotation))
@ -859,9 +860,12 @@ bool rarch_environment_cb(unsigned cmd, void *data)
break;
case RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL:
if (system)
{
system->performance_level = *(const unsigned*)data;
RARCH_LOG("Environ PERFORMANCE_LEVEL: %u.\n",
system->performance_level);
}
break;
case RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY:
@ -938,7 +942,6 @@ bool rarch_environment_cb(unsigned cmd, void *data)
{
unsigned retro_id;
const struct retro_input_descriptor *desc = NULL;
static const char *libretro_btn_desc[] = {
"B (bottom)", "Y (left)", "Select", "Start",
"D-Pad Up", "D-Pad Down", "D-Pad Left", "D-Pad Right",
@ -1054,6 +1057,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
case RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE:
RARCH_LOG("Environ SET_DISK_CONTROL_INTERFACE.\n");
if (system)
system->disk_control_cb =
*(const struct retro_disk_control_callback*)data;
break;
@ -1252,6 +1256,8 @@ bool rarch_environment_cb(unsigned cmd, void *data)
cb->stop = driver_location_stop;
cb->get_position = driver_location_get_position;
cb->set_interval = driver_location_set_interval;
if (system)
system->location_cb = *cb;
location_driver_ctl(RARCH_LOCATION_CTL_UNSET_ACTIVE, NULL);
@ -1323,6 +1329,8 @@ bool rarch_environment_cb(unsigned cmd, void *data)
}
}
if (system)
{
free(system->subsystem.data);
system->subsystem.data = (struct retro_subsystem_info*)
calloc(i, sizeof(*system->subsystem.data));
@ -1333,6 +1341,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
memcpy(system->subsystem.data, info,
i * sizeof(*system->subsystem.data));
system->subsystem.size = i;
}
break;
}