From 21a645df00ff129f30984c95aa8f8abd2fe43ae9 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 27 Jul 2022 13:39:44 -0700 Subject: [PATCH] queue: when flattening sets, unref dependencies that will not be re-added --- libpkgconf/queue.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libpkgconf/queue.c b/libpkgconf/queue.c index d11e03d..51006ef 100644 --- a/libpkgconf/queue.c +++ b/libpkgconf/queue.c @@ -147,11 +147,11 @@ dep_sort_cmp(const void *a, const void *b) static inline void flatten_dependency_set(pkgconf_client_t *client, pkgconf_list_t *list) { - pkgconf_node_t *node; + pkgconf_node_t *node, *next; pkgconf_dependency_t **deps = NULL; size_t dep_count = 0, i; - PKGCONF_FOREACH_LIST_ENTRY(list->head, node) + PKGCONF_FOREACH_LIST_ENTRY_SAFE(list->head, next, node) { pkgconf_dependency_t *dep = node->data; pkgconf_pkg_t *pkg = pkgconf_pkg_verify_dependency(client, dep, NULL); @@ -161,6 +161,8 @@ flatten_dependency_set(pkgconf_client_t *client, pkgconf_list_t *list) if (pkg->serial == client->serial) { + PKGCONF_TRACE(client, "dedup %s serials match", pkg->id); + pkgconf_dependency_unref(dep->owner, dep); goto next; } @@ -180,6 +182,7 @@ flatten_dependency_set(pkgconf_client_t *client, pkgconf_list_t *list) if (!strcmp(dep->package, other_dep->package)) { PKGCONF_TRACE(client, "skipping, %zu deps", dep_count); + pkgconf_dependency_unref(dep->owner, dep); goto next; } }