]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-parser: when we parse a string list, always fill in something
authorLennart Poettering <lennart@poettering.net>
Sat, 23 Mar 2013 03:32:43 +0000 (04:32 +0100)
committerLennart Poettering <lennart@poettering.net>
Sat, 23 Mar 2013 03:32:43 +0000 (04:32 +0100)
Some code really wants to know whether there was a string list parsed,
so don't take the shortcut here, and always allocate a string list, even
if it is an empty one.

https://bugs.freedesktop.org/show_bug.cgi?id=62558

src/shared/conf-parser.c

index b09e90ae8bd40c672c338b1073f09fa34d6f6819..c2cf5a6a196d08e4f070770c070ac9a651a418d6 100644 (file)
@@ -705,9 +705,18 @@ int config_parse_strv(
         assert(data);
 
         if (isempty(rvalue)) {
-                /* Empty assignment resets the list */
+                char **empty;
+
+                /* Empty assignment resets the list. As a special rule
+                 * we actually fill in a real empty array here rather
+                 * than NULL, since some code wants to know if
+                 * something was set at all... */
+                empty = strv_new(NULL, NULL);
+                if (!empty)
+                        return log_oom();
+
                 strv_free(*sv);
-                *sv = NULL;
+                *sv = empty;
                 return 0;
         }