From 4589f5bb0a973e9a41be93de06c87072cea4dfb9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 23 Mar 2013 04:32:43 +0100 Subject: [PATCH] conf-parser: when we parse a string list, always fill in something 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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index b09e90ae8..c2cf5a6a1 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -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; } -- 2.30.2