Skip to content

Commit

Permalink
Don't use r if malloc fails.
Browse files Browse the repository at this point in the history
coverity: 1450949
  • Loading branch information
Linus Nordberg committed Aug 1, 2017
1 parent 809c10e commit 1caa9c3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ char *stringcopy(const char *s, int len) {
r = malloc(len + 1);
if (!r)
debug(DBG_ERR, "stringcopy: malloc failed");
memcpy(r, s, len);
r[len] = '\0';
else {
memcpy(r, s, len);
r[len] = '\0';
}
return r;
}

Expand Down

0 comments on commit 1caa9c3

Please sign in to comment.