Permalink
Browse files

Correctly report allocation failure in argv_append

  • Loading branch information...
1 parent 9df8039 commit e35b50dadc1c29b474715b89eeb1508663710452 @jonas jonas committed Aug 23, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 io.c
View
8 io.c
@@ -113,16 +113,20 @@ bool
argv_append(const char ***argv, const char *arg)
{
size_t argc = argv_size(*argv);
+ char *alloc;
if (!*arg && argc > 0)
return TRUE;
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

0 comments on commit e35b50d

Please sign in to comment.