From: Lennart Poettering Date: Sat, 23 Mar 2013 03:32:43 +0000 (+0100) Subject: conf-parser: when we parse a string list, always fill in something X-Git-Tag: v199~58 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=4589f5bb0a973e9a41be93de06c87072cea4dfb9 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 --- 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; }