From e35b50dadc1c29b474715b89eeb1508663710452 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Wed, 22 Aug 2012 22:13:05 -0400 Subject: [PATCH] Correctly report allocation failure in argv_append --- io.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/io.c b/io.c index 0c1a8f752..e96634c98 100644 --- a/io.c +++ b/io.c @@ -113,6 +113,7 @@ bool argv_append(const char ***argv, const char *arg) { size_t argc = argv_size(*argv); + char *alloc; if (!*arg && argc > 0) return TRUE; @@ -120,9 +121,12 @@ argv_append(const char ***argv, const char *arg) if (!argv_realloc(argv, argc, 2)) return FALSE; - (*argv)[argc++] = strdup(arg); + alloc = strdup(arg); + + (*argv)[argc++] = alloc; (*argv)[argc] = NULL; - return TRUE; + + return alloc != NULL; } bool