diff options
author | Linus Nordberg <linus@nordu.net> | 2017-07-30 21:46:29 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2017-08-01 18:25:36 +0200 |
commit | 1caa9c33330c1927fd9435d919607d513d8b3f89 (patch) | |
tree | 2ff335c0534e5e5bb7cd2857888a3526dd922b83 /util.c | |
parent | 809c10eeac1df4719ab2a9a16105666da0b39f35 (diff) |
Don't use r if malloc fails.
coverity: 1450949
Diffstat (limited to 'util.c')
-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; } |