summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-05-07 08:45:20 -0400
committerDave Reisner <dreisner@archlinux.org>2013-05-07 08:45:20 -0400
commit3b880c5b5f7abefaf8bd97031e37740be575d52f (patch)
tree682e79c215b592d746adbcefdd34265b40fb64d5
parenta6e67c3827b6c723d57b9252b5679ca0d48cc17b (diff)
downloadexpac-3b880c5b5f7abefaf8bd97031e37740be575d52f.tar.xz
check return of asprintf
-rw-r--r--expac.c11
1 files 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';