strv: handle empty lists in strv_copy() properly

This commit is contained in:
Lennart Poettering
2011-04-16 02:03:34 +02:00
parent 6f9a471aa6
commit ede27aab11
+4 -3
View File
@@ -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;