pkg: assert a package being freed has 0 references

Dylan Baker 2022-07-26 14:06:18 -07:00
parent 0f4f170ce2
commit 283050cc42
2 changed files with 5 additions and 1 deletions

View File

@ -233,7 +233,7 @@ pkgconf_cache_free(pkgconf_client_t *client)
for (i = 0, count = client->cache_count; i < count; i++)
{
pkgconf_pkg_t *pkg = cache_table[i];
pkgconf_pkg_free(client, pkg);
pkgconf_pkg_unref(client, pkg);
}
free(cache_table);

View File

@ -17,6 +17,8 @@
#include <libpkgconf/stdinc.h>
#include <libpkgconf/libpkgconf.h>
#include <assert.h>
/*
* !doc
*
@ -514,6 +516,8 @@ pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
if (pkg->pc_filedir != NULL)
free(pkg->pc_filedir);
/* We shouldn't be trying to free this if someone is still holding a reference to it */
assert(pkg->refcount == 0);
free(pkg);
}