From: Lennart Poettering Date: Fri, 15 Apr 2011 23:49:20 +0000 (+0200) Subject: strv: handle empty lists in strv_copy() properly X-Git-Tag: v25~38 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=ede27aab11cda3f55c2cd2e1e28e2385b3f64453 strv: handle empty lists in strv_copy() properly --- diff --git a/src/strv.c b/src/strv.c index c5f8df06d..c8ebb648d 100644 --- a/src/strv.c +++ b/src/strv.c @@ -70,9 +70,10 @@ char **strv_copy(char **l) { if (!(r = new(char*, strv_length(l)+1))) return NULL; - for (k = r; *l; k++, l++) - if (!(*k = strdup(*l))) - goto fail; + if (l) + for (k = r; *l; k++, l++) + if (!(*k = strdup(*l))) + goto fail; *k = NULL; return r;