From 36acd2e4098f8ead13e9ac1a374ca3e0e621b7d9 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 28 Jul 2022 10:57:30 -0700 Subject: [PATCH] queue: don't collect static dependencies unless that's what we're looking for Currently the required_private field gets walked twice, once when the main required field is walked, and a second time when it is walked itself. This results in the requires_private field leaking memory. --- libpkgconf/queue.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/libpkgconf/queue.c b/libpkgconf/queue.c index b1b44f0..1ef8c07 100644 --- a/libpkgconf/queue.c +++ b/libpkgconf/queue.c @@ -116,22 +116,26 @@ pkgconf_queue_collect_dependents(pkgconf_client_t *client, pkgconf_pkg_t *pkg, v if (pkg == world) return; - PKGCONF_FOREACH_LIST_ENTRY(pkg->required.head, node) - { - pkgconf_dependency_t *flattened_dep; + if ((pkg->flags & PKGCONF_PKG_PROPF_STATIC) == PKGCONF_PKG_PROPF_STATIC) { + PKGCONF_FOREACH_LIST_ENTRY(pkg->requires_private.head, node) + { + pkgconf_dependency_t *flattened_dep; - flattened_dep = pkgconf_dependency_copy(client, node->data); + flattened_dep = pkgconf_dependency_copy(client, node->data); - pkgconf_node_insert(&flattened_dep->iter, flattened_dep, &world->required); + pkgconf_node_insert(&flattened_dep->iter, flattened_dep, &world->requires_private); + } } - - PKGCONF_FOREACH_LIST_ENTRY(pkg->requires_private.head, node) + else { - pkgconf_dependency_t *flattened_dep; + PKGCONF_FOREACH_LIST_ENTRY(pkg->required.head, node) + { + pkgconf_dependency_t *flattened_dep; - flattened_dep = pkgconf_dependency_copy(client, node->data); + flattened_dep = pkgconf_dependency_copy(client, node->data); - pkgconf_node_insert(&flattened_dep->iter, flattened_dep, &world->requires_private); + pkgconf_node_insert(&flattened_dep->iter, flattened_dep, &world->required); + } } }