X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fstrv.c;fp=src%2Fstrv.c;h=640ae3f0a3dacddd967834fb1fa5320cd5a58cb6;hp=92851b223375516b5144f52afcc2ca4b471333fd;hb=8ea913b2eaadbd92e069ea6b71cc5f5df409decf;hpb=0fe9972f3c2e20b649e0e7da0e61945253622128 diff --git a/src/strv.c b/src/strv.c index 92851b223..640ae3f0a 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;