From ede27aab11cda3f55c2cd2e1e28e2385b3f64453 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 16 Apr 2011 01:49:20 +0200 Subject: [PATCH] strv: handle empty lists in strv_copy() properly --- src/strv.c | 7 ++++--- 1 file 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; -- 2.30.2