From 3b880c5b5f7abefaf8bd97031e37740be575d52f Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 7 May 2013 08:45:20 -0400 Subject: check return of asprintf --- expac.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/expac.c b/expac.c index 1ded409..eba37bd 100644 --- a/expac.c +++ b/expac.c @@ -140,7 +140,9 @@ static char *strtrim(char *str) { static char *format_optdep(alpm_depend_t *optdep) { char *out; - asprintf(&out, "%s: %s", optdep->name, optdep->desc); + if (asprintf(&out, "%s: %s", optdep->name, optdep->desc) < 0) { + return NULL; + } return out; } @@ -380,9 +382,10 @@ static int print_list(alpm_list_t *list, extractfn fn, bool shortdeps) { i = list; while (1) { - char *item; - - item = (char*)(fn ? fn(i->data) : i->data); + char *item = (char*)(fn ? fn(i->data) : i->data); + if (item == NULL) { + continue; + } if (shortdeps) { *(item + strcspn(item, "<>=")) = '\0'; -- cgit v1.2.3-54-g00ecf