diff options
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; |