diff options
author | Dave Reisner <dreisner@archlinux.org> | 2013-05-07 08:45:20 -0400 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2013-05-07 08:45:20 -0400 |
commit | 3b880c5b5f7abefaf8bd97031e37740be575d52f (patch) | |
tree | 682e79c215b592d746adbcefdd34265b40fb64d5 | |
parent | a6e67c3827b6c723d57b9252b5679ca0d48cc17b (diff) | |
download | expac-3b880c5b5f7abefaf8bd97031e37740be575d52f.tar.xz |
check return of asprintf
-rw-r--r-- | expac.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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'; |