chiark / gitweb /
conf-parser: don't crash when environemnt list is empty
authorLennart Poettering <lennart@poettering.net>
Tue, 6 Apr 2010 00:37:47 +0000 (02:37 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 6 Apr 2010 00:37:47 +0000 (02:37 +0200)
conf-parser.c

index aebf61a..8883d9e 100644 (file)
@@ -368,8 +368,10 @@ int config_parse_strv(
         if (!(n = new(char*, k+1)))
                 return -ENOMEM;
 
-        for (k = 0; (*sv)[k]; k++)
-                n[k] = (*sv)[k];
+        if (*sv)
+                for (k = 0; (*sv)[k]; k++)
+                        n[k] = (*sv)[k];
+
         FOREACH_WORD_QUOTED(w, l, rvalue, state)
                 if (!(n[k++] = strndup(w, l)))
                         goto fail;