]> git.ipfire.org Git - pakfire.git/commitdiff
solution: Actually terminate the array
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 3 Jul 2021 13:35:12 +0000 (13:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 3 Jul 2021 13:35:12 +0000 (13:35 +0000)
The for loop was off by one

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

index 9a2f9c4a67453db88db0062c690e8def07389300..325670ce05a54dd73cd3f1b1869b2e30f2197943 100644 (file)
@@ -110,10 +110,6 @@ static char* pakfire_solution_make_string(struct pakfire_solution* solution) {
        // Allocate memory for all strings
        char* elements[count + 1];
 
-       // Initialize the array
-       for (unsigned int i = 0; i < count; i++)
-               elements[i] = NULL;
-
        // The result string
        char* s = NULL;
 
@@ -184,6 +180,9 @@ static char* pakfire_solution_make_string(struct pakfire_solution* solution) {
                elements[i] = element;
        }
 
+       // Terminate the array
+       elements[count] = NULL;
+
        // All okay, concat result string
        s = pakfire_string_join(elements, "\n");