From 53a76972f56688f4e0c7889e295d87b91ae85bc5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 12 Sep 2017 01:51:17 +0300 Subject: Fix leaks and package not caching --- libpkgconf/pkg.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libpkgconf/pkg.c') diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index bcfb486..59957ff 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -16,6 +16,8 @@ #include #include +#include + /* * !doc * @@ -407,6 +409,13 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * void pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg) { + // The function leaks (issue #132 is reported). The whole concept of "static" + // packages is quite murky, so it's better just not to use it, at least + // until fixed by the library owners. In particular don't use + // pkgconf_queue_* functions. + // + assert (pkg == NULL || (pkg->flags & PKGCONF_PKG_PROPF_STATIC) == 0); + if (pkg == NULL || pkg->flags & PKGCONF_PKG_PROPF_STATIC) return; @@ -672,6 +681,10 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name) if (pkg != NULL) { pkgconf_path_add(pkg_get_parent_dir(pkg), &client->dir_list, true); + + // Add the package to the cache (issue #133 is reported). + // + pkgconf_cache_add(client, pkg); return pkg; } } -- cgit v1.1