Summary:
I thought its better to fail and return null if realloc fails than to
continue. So returning by closing all openend file.
Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>
Reviewers: cedric, illogict
Differential Revision: https://phab.enlightenment.org/D3232
{
FILE *f;
char line[256], label[256], value[256];
- FB_Mode *modes = NULL;
+ FB_Mode *modes = NULL, *temp;
int num;
num = 0;
int timings = 0;
num++;
+ temp = modes;
modes = realloc(modes, num * sizeof(FB_Mode));
+ if (!modes)
+ {
+ free(temp);
+ fclose(f);
+ *num_return = 0;
+ return NULL;
+ }
memset(modes + (num - 1), 0, sizeof(FB_Mode));
modes[num - 1].width = atoi(f1);
modes[num - 1].height = atoi(f2);