Be more careful with allocations

This commit is contained in:
twinaphex 2016-12-25 01:52:40 +01:00
parent 2156bb43a1
commit bb4888ae22

View File

@ -80,6 +80,7 @@ struct state_tracker
state_tracker_t* state_tracker_init(const struct state_tracker_info *info)
{
unsigned i;
struct state_tracker_internal *tracker_info = NULL;
state_tracker_t *tracker = (state_tracker_t*)calloc(1, sizeof(*tracker));
if (!tracker)
return NULL;
@ -99,16 +100,17 @@ state_tracker_t* state_tracker_init(const struct state_tracker_info *info)
}
#endif
tracker->info = (struct state_tracker_internal*)
tracker_info = (struct state_tracker_internal*)
calloc(info->info_elem, sizeof(struct state_tracker_internal));
if (!tracker->info)
if (!tracker_info)
{
RARCH_ERR("Allocation of state tracker info failed.\n");
free(tracker);
return NULL;
}
tracker->info = tracker_info;
tracker->info_elem = info->info_elem;
for (i = 0; i < info->info_elem; i++)