]> git.ipfire.org Git - pakfire.git/commitdiff
config: Properly terminate the sections array
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 16 Apr 2021 16:15:32 +0000 (16:15 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 16 Apr 2021 16:15:32 +0000 (16:15 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/config.c

index b64947ef52f401aa3ee088b1fa0a6040b233dea2..55e3c8313c847cd3a6df3c82c7d6c5d75c7b7731 100644 (file)
@@ -234,13 +234,17 @@ char** pakfire_config_sections(struct pakfire_config* config) {
                        continue;
 
                // Make space in the array
-               sections = reallocarray(sections, sizeof(*sections), num_sections++ + 1);
+               sections = reallocarray(sections, sizeof(*sections), ++num_sections + 1);
                if (!sections)
                        return NULL;
 
                sections[num_sections - 1] = strdup(entry->section);
        }
 
+       // Terminate the array
+       if (num_sections)
+               sections[num_sections] = NULL;
+
        return sections;
 }