Skip to content

Commit

Permalink
Correctly report allocation failure in argv_append
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas committed Aug 23, 2012
1 parent 9df8039 commit e35b50d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e35b50d

Please sign in to comment.