diff options
author | Linus Nordberg <linus@nordu.net> | 2017-07-30 21:46:29 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2017-07-30 21:46:29 +0200 |
commit | c2624d484fd8034bd498d0573e43baee7faceae4 (patch) | |
tree | b70c757195e48b000f10ccd007a308e85d8b37b7 | |
parent | dc55291f5b206bf33e34e6730eeccb3b3fc3f9d8 (diff) |
Don't use r if malloc fails.
coverity: 1450949
-rw-r--r-- | util.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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; } |