summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2014-01-06 17:52:26 +0100
committerAllan McRae <allan@archlinux.org>2014-01-30 05:22:27 +0100
commitaa4d3298fb6d46bec3d8996ff8c7ec8c9cc50db9 (patch)
tree5ffcfabe99d71d2de121a4aa35d34f9114cff06b /src
parentc2edd31eae73c9a4bf7b62e41a12fd5c3bba2ce0 (diff)
downloadpacman-aa4d3298fb6d46bec3d8996ff8c7ec8c9cc50db9.tar.gz
pacman-aa4d3298fb6d46bec3d8996ff8c7ec8c9cc50db9.tar.xz
table_display: free memory on errors
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/util.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index d7a5e01f..91f8fb3b 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -587,9 +587,10 @@ static int table_display(const alpm_list_t *header,
const alpm_list_t *i, *first;
size_t *widths = NULL, totalcols, totalwidth;
int *has_data = NULL;
+ int ret = 0;
if(rows == NULL) {
- return 0;
+ return ret;
}
/* 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) {
pm_printf(ALPM_LOG_WARNING,
_("insufficient columns available for table display\n"));
- return -1;
+ ret = -1;
+ goto cleanup;
}
if(!totalwidth || !widths || !has_data) {
- return -1;
+ ret = -1;
+ goto cleanup;
}
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);
}
+cleanup:
free(widths);
free(has_data);
- return 0;
+ return ret;
}
void list_display(const char *title, const alpm_list_t *list,