]> git.ipfire.org Git - pakfire.git/commitdiff
db: Ensure to free the deps list after each iteration
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 Feb 2025 15:43:53 +0000 (15:43 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 Feb 2025 15:43:53 +0000 (15:43 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/db.c

index 52507fcdb38060ffbce84c23c6a3164050517563..545f8b962e8918a66467c44ccac7f2e80e6d7516 100644 (file)
@@ -960,6 +960,12 @@ static int pakfire_db_add_dependencies(struct pakfire_db* db, unsigned long id,
                        // Reset bound values
                        sqlite3_reset(stmt);
                }
+
+               // Free the list
+               if (list) {
+                       pakfire_strings_free(list);
+                       list = NULL;
+               }
        }
 
        // All okay
@@ -968,11 +974,8 @@ static int pakfire_db_add_dependencies(struct pakfire_db* db, unsigned long id,
 END:
        if (stmt)
                sqlite3_finalize(stmt);
-       if (list) {
-               for (char** dep = list; *dep; dep++)
-                       free(*dep);
-               free(list);
-       }
+       if (list)
+               pakfire_strings_free(list);
 
        return r;
 }