]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: parser: Fix when namespace is NULL
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 Jun 2019 02:44:40 +0000 (03:44 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 Jun 2019 02:44:40 +0000 (03:44 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser.c

index 60d0f0b31319daec96b8314a55b55804e7a0de09..81b216a24bde887fc43219be47e5ea63225746c5 100644 (file)
@@ -261,13 +261,13 @@ static struct pakfire_parser_declaration* pakfire_parser_find_declaration(
        // Create a working copy of the namespace
        char* n = pakfire_strdup(parser->namespace);
 
-       size_t length = strlen(n) + strlen(name) + 1;
+       size_t length = (n) ? strlen(n) : 0 + strlen(name) + 1;
        char* buffer = pakfire_malloc(length + 1);
 
        struct pakfire_parser_declaration* d = NULL;
 
        while (1) {
-               if (*n)
+               if (n && *n)
                        snprintf(buffer, length + 1, "%s.%s", n, name);
                else
                        snprintf(buffer, length + 1, "%s", name);