Skip to content

Commit

Permalink
Exit if stringcopy() fails at allocating memory.
Browse files Browse the repository at this point in the history
Writing to 0 seems unwise to me.
Returning NULL will simply move the problem to the callers.
I admit that a better fix would be to fix all the callers.
  • Loading branch information
Linus Nordberg committed Oct 18, 2016
1 parent 6a45e69 commit 28037df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion util.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ char *stringcopy(const char *s, int len) {
len = strlen(s);
r = malloc(len + 1);
if (!r)
debug(DBG_ERR, "stringcopy: malloc failed");
debugx(1, DBG_ERR, "stringcopy: malloc failed");
memcpy(r, s, len);
r[len] = '\0';
return r;
Expand Down

0 comments on commit 28037df

Please sign in to comment.