From 795c2a58f578d644b24a3bcada992b63b5130106 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 7 Nov 2009 16:41:59 +0100 Subject: [PATCH] Fix some issues while matching for required pkgdeps. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091107154159-riikhswt1h3mm9xn --- lib/depends.c | 15 +++++++++++++-- lib/pkgmatch.c | 2 ++ lib/util.c | 6 +++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/depends.c b/lib/depends.c index 967f53e0..a97b4351 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -279,12 +279,23 @@ find_repo_deps(prop_dictionary_t master, prop_dictionary_t repo, /* * Check if required dep is satisfied and installed. */ - if (xbps_check_is_installed_pkg(reqpkg)) + rv = xbps_check_is_installed_pkg(reqpkg); + if (rv == -1) { + /* There was an error checking it... */ + break; + } else if (rv == 1) { + /* pkgdep is satisfied */ continue; + } pkgname = xbps_get_pkgdep_name(reqpkg); + if (pkgname == NULL) { + rv = EINVAL; + break; + } reqvers = xbps_get_pkgdep_version(reqpkg); - if (pkgname == NULL || reqvers == NULL) { + if (reqvers == NULL) { + free(pkgname); rv = EINVAL; break; } diff --git a/lib/pkgmatch.c b/lib/pkgmatch.c index 81b83a80..0c0fc373 100644 --- a/lib/pkgmatch.c +++ b/lib/pkgmatch.c @@ -113,6 +113,8 @@ xbps_pkgdep_match(const char *instpkg, char *pattern) char basefname[PATH_MAX], condchar = '\0', *condition; int rv = 0; + memset(&basefname, 0, sizeof(basefname)); + condition = strpbrk(pattern, "><="); if (condition) { const char *ch; diff --git a/lib/util.c b/lib/util.c index a6c90eae..b0b521ea 100644 --- a/lib/util.c +++ b/lib/util.c @@ -141,16 +141,16 @@ xbps_check_is_installed_pkg(const char *pkg) free(pkgname); return -1; } - free(pkgname); - if (state != XBPS_PKG_STATE_INSTALLED) { prop_object_release(dict); - return 0; + free(pkgname); + return 0; /* not fully installed */ } /* Get version from installed package */ prop_dictionary_get_cstring_nocopy(dict, "version", &instver); instpkg = xbps_xasprintf("%s-%s", pkgname, instver); + free(pkgname); if (instpkg == NULL) { prop_object_release(dict); return -1;