1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-16 14:25:21 -05:00

table_display: free memory on errors

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Andrew Gregory 2014-01-06 11:52:26 -05:00 committed by Allan McRae
parent c2edd31eae
commit aa4d3298fb

View File

@ -587,9 +587,10 @@ static int table_display(const alpm_list_t *header,
const alpm_list_t *i, *first; const alpm_list_t *i, *first;
size_t *widths = NULL, totalcols, totalwidth; size_t *widths = NULL, totalcols, totalwidth;
int *has_data = NULL; int *has_data = NULL;
int ret = 0;
if(rows == NULL) { if(rows == NULL) {
return 0; return ret;
} }
/* we want the first row. if no headers are provided, use the first /* we want the first row. if no headers are provided, use the first
@ -603,10 +604,12 @@ static int table_display(const alpm_list_t *header,
if(totalwidth > cols) { if(totalwidth > cols) {
pm_printf(ALPM_LOG_WARNING, pm_printf(ALPM_LOG_WARNING,
_("insufficient columns available for table display\n")); _("insufficient columns available for table display\n"));
return -1; ret = -1;
goto cleanup;
} }
if(!totalwidth || !widths || !has_data) { if(!totalwidth || !widths || !has_data) {
return -1; ret = -1;
goto cleanup;
} }
if(header) { if(header) {
@ -618,9 +621,10 @@ static int table_display(const alpm_list_t *header,
table_print_line(i->data, padding, totalcols, widths, has_data); table_print_line(i->data, padding, totalcols, widths, has_data);
} }
cleanup:
free(widths); free(widths);
free(has_data); free(has_data);
return 0; return ret;
} }
void list_display(const char *title, const alpm_list_t *list, void list_display(const char *title, const alpm_list_t *list,