diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-09-23 01:43:28 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-09-23 01:45:34 +0200 |
commit | 8ea913b2eaadbd92e069ea6b71cc5f5df409decf (patch) | |
tree | 17801331900df94b4cf05fa232d755fac7f3929a /src/strv.c | |
parent | 0fe9972f3c2e20b649e0e7da0e61945253622128 (diff) |
coverity: fix a couple of bugs found by coverity
Diffstat (limited to 'src/strv.c')
-rw-r--r-- | src/strv.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/strv.c b/src/strv.c index 92851b2233..640ae3f0a3 100644 --- a/src/strv.c +++ b/src/strv.c @@ -201,12 +201,19 @@ char **strv_merge_concat(char **a, char **b, const char *suffix) { if (!(r = new(char*, strv_length(a)+strv_length(b)+1))) return NULL; - for (k = r; *a; k++, a++) - if (!(*k = strdup(*a))) - goto fail; - for (; *b; k++, b++) - if (!(*k = strappend(*b, suffix))) + k = r; + if (a) + for (; *a; k++, a++) { + *k = strdup(*a); + if (!*k) + goto fail; + } + + for (; *b; k++, b++) { + *k = strappend(*b, suffix); + if (!*k) goto fail; + } *k = NULL; return r; |