mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-12 21:08:15 +00:00
Be more careful with allocations
This commit is contained in:
parent
2156bb43a1
commit
bb4888ae22
@ -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++)
|
||||
|
Loading…
Reference in New Issue
Block a user