When gpt_disk_get_partition_info() discovers that a partition is
invalid, it returns error, but it forgets to free its allocations.
Found by covscan.
Signed-off-by: Peter Jones <pjones@redhat.com>
gpt_entry *ptes = NULL, *p;
int rc = 0;
- char *report=getenv("LIBEFIBOOT_REPORT_GPT_ERRORS");
+ char *report = getenv("LIBEFIBOOT_REPORT_GPT_ERRORS");
if (report)
report_errors = 1;
if (report_errors)
fprintf(stderr, "partition %d is not valid\n", num);
errno = EINVAL;
- return -1;
+ rc = -1;
}
- if (ptes)
- free(ptes);
- if (gpt)
- free(gpt);
+ free(ptes);
+ free(gpt);
return rc;
}