summaryrefslogtreecommitdiff
path: root/src/strv.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-04-16 01:49:20 +0200
committerLennart Poettering <lennart@poettering.net>2011-04-16 02:03:34 +0200
commitede27aab11cda3f55c2cd2e1e28e2385b3f64453 (patch)
tree526715f3f455eb34f82ed3f6cc2cd4e806b86cc5 /src/strv.c
parent6f9a471aa677ff4048aea168d7cea3697cf51fb3 (diff)
strv: handle empty lists in strv_copy() properly
Diffstat (limited to 'src/strv.c')
-rw-r--r--src/strv.c7
1 files changed, 4 insertions, 3 deletions
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;