diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-04-16 01:49:20 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-04-16 02:03:34 +0200 |
commit | ede27aab11cda3f55c2cd2e1e28e2385b3f64453 (patch) | |
tree | 526715f3f455eb34f82ed3f6cc2cd4e806b86cc5 /src/strv.c | |
parent | 6f9a471aa677ff4048aea168d7cea3697cf51fb3 (diff) |
strv: handle empty lists in strv_copy() properly
Diffstat (limited to 'src/strv.c')
-rw-r--r-- | src/strv.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/strv.c b/src/strv.c index c5f8df06da..c8ebb648d6 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; |