From 679833156a9c223d05e175e5f49ea076fbf35093 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 8 Nov 2010 02:02:35 +0100 Subject: [PATCH] Always release the object dictionary returned by xbps_find_pkg_dict_installed(). Document this in the public API header and update all code accordingly. --- bin/xbps-bin/check.c | 3 +-- bin/xbps-bin/remove.c | 3 +++ include/xbps_api.h | 5 ++++- lib/package_state.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/xbps-bin/check.c b/bin/xbps-bin/check.c index e1834a24..ab41b547 100644 --- a/bin/xbps-bin/check.c +++ b/bin/xbps-bin/check.c @@ -105,6 +105,7 @@ xbps_check_pkg_integrity(const char *pkgname) printf("Package %s is not installed.\n", pkgname); return 0; } + prop_object_release(pkgd); /* * Check for props.plist metadata file. @@ -296,8 +297,6 @@ out: prop_object_release(filesd); if (propsd) prop_object_release(propsd); - if (pkgd) - prop_object_release(pkgd); if (broken) rv = EINVAL; diff --git a/bin/xbps-bin/remove.c b/bin/xbps-bin/remove.c index 4191df7d..22c9fa4d 100644 --- a/bin/xbps-bin/remove.c +++ b/bin/xbps-bin/remove.c @@ -161,6 +161,7 @@ xbps_remove_installed_pkgs(int argc, char **argv, bool force, bool purge) "PACKAGES!\n", argv[i], version); reqby_force = true; } + prop_object_release(dict); } if (!found) return 0; @@ -185,6 +186,7 @@ xbps_remove_installed_pkgs(int argc, char **argv, bool force, bool purge) cols = strlen(argv[i]) + strlen(version) + 4; } printf("%s-%s ", argv[i], version); + prop_object_release(dict); } printf("\n\n"); if (!force && !xbps_noyes("Do you want to continue?")) { @@ -199,6 +201,7 @@ xbps_remove_installed_pkgs(int argc, char **argv, bool force, bool purge) if (dict == NULL) continue; prop_dictionary_get_cstring_nocopy(dict, "version", &version); + prop_object_release(dict); if ((rv = pkg_remove_and_purge(argv[i], version, purge)) != 0) return rv; } diff --git a/include/xbps_api.h b/include/xbps_api.h index a353f84b..c3b9c997 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -125,6 +125,7 @@ extern "C" { */ #define XBPS_FLAG_FORCE 0x00000002 + /** * @cond */ @@ -478,7 +479,9 @@ prop_dictionary_t xbps_find_pkg_from_plist(const char *plist, * by using a package pattern. If false, \a str is assumed to be a package name. * * @return The package's dictionary on success, NULL otherwise and - * errno is set appropiately. + * errno is set appropiately. Returned dictionary is copied via + * prop_dictionary_copy(), which means that caller is responsible to + * release the object with prop_object_release() when done. */ prop_dictionary_t xbps_find_pkg_dict_installed(const char *str, bool bypattern); diff --git a/lib/package_state.c b/lib/package_state.c index f9e2917c..a980147c 100644 --- a/lib/package_state.c +++ b/lib/package_state.c @@ -114,6 +114,7 @@ xbps_get_pkg_state_installed(const char *pkgname, pkg_state_t *state) return errno; *state = get_state(pkgd); + prop_object_release(pkgd); if (*state == 0) return EINVAL;