From: Jo-Philipp Wich Date: Fri, 10 Feb 2017 09:28:09 +0000 (+0100) Subject: libopkg: discard empty control file fields X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ae179dcbb64f8797235f20521ac7dfcf3ce65ce4;p=oweals%2Fopkg-lede.git libopkg: discard empty control file fields If the resulting string is empty after whitespace trimming, free it and store NULL instead of an empty string buffer. Signed-off-by: Jo-Philipp Wich --- diff --git a/libopkg/parse_util.c b/libopkg/parse_util.c index fbecba6..2aef7a9 100644 --- a/libopkg/parse_util.c +++ b/libopkg/parse_util.c @@ -35,7 +35,12 @@ is_field(const char *type, const char *line) char * parse_simple(const char *type, const char *line) { - return trim_xstrdup(line + strlen(type) + 1); + char *field = trim_xstrdup(line + strlen(type) + 1); + if (strlen(field) == 0) { + free(field); + return NULL; + } + return field; } /*