]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: parser: Return NULL for empty values
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 8 Jun 2019 14:34:26 +0000 (15:34 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 8 Jun 2019 14:34:26 +0000 (15:34 +0100)
This avoids checking for NULL and empty string further down the line

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser.c

index 970a977f7e1d4f428b68251c0d2060d2b1b27ed1..220d9431c7be7493e80fd0963b1c21be300b25da 100644 (file)
@@ -227,9 +227,13 @@ PAKFIRE_EXPORT int pakfire_parser_set(PakfireParser parser, const char* name, co
 static const char* pakfire_parser_get_raw(PakfireParser parser, const char* name) {
        struct pakfire_parser_declaration* d = pakfire_parser_get_declaration(parser, name);
 
-       // Return a match
-       if (d)
-               return d->value;
+       // Return a match when it actually contains a string
+       if (d) {
+               if (d->value && *d->value)
+                       return d->value;
+
+               return NULL;
+       }
 
        // Search in parent parser if available
        if (parser->parent)