lib/plist_find.c: fix a memleak, misc cleanups.

This commit is contained in:
Juan RP 2013-08-29 11:51:42 +02:00
parent a039330f3c
commit 6795e840d6

View File

@ -164,9 +164,10 @@ match_pkg_by_pattern(xbps_dictionary_t repod, const char *p)
/* match by pkgpattern in pkgver */ /* match by pkgpattern in pkgver */
if ((pkgname = xbps_pkgpattern_name(p)) == NULL) { if ((pkgname = xbps_pkgpattern_name(p)) == NULL) {
if ((pkgname = xbps_pkg_name(p))) if ((pkgname = xbps_pkg_name(p))) {
free(pkgname);
return match_pkg_by_pkgver(repod, p); return match_pkg_by_pkgver(repod, p);
}
return NULL; return NULL;
} }
@ -199,6 +200,7 @@ config_inject_vpkgs(struct xbps_handle *xh)
if ((dirp = opendir(vpkgdir)) == NULL) { if ((dirp = opendir(vpkgdir)) == NULL) {
xbps_dbg_printf(xh, "cannot access to %s: %s\n", xbps_dbg_printf(xh, "cannot access to %s: %s\n",
vpkgdir, strerror(errno)); vpkgdir, strerror(errno));
free(vpkgdir);
return; return;
} }
@ -298,7 +300,7 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
xbps_object_iterator_t iter; xbps_object_iterator_t iter;
xbps_dictionary_t pkgd = NULL; xbps_dictionary_t pkgd = NULL;
const char *vpkg; const char *vpkg;
bool found = false, bypattern = false; bool bypattern = false;
if (xbps_pkgpattern_version(pkg)) if (xbps_pkgpattern_version(pkg))
bypattern = true; bypattern = true;
@ -313,10 +315,8 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
else else
pkgd = xbps_dictionary_get(d, vpkg); pkgd = xbps_dictionary_get(d, vpkg);
if (pkgd) { if (pkgd)
found = true; return pkgd;
goto out;
}
} }
/* ... otherwise match the first one in dictionary */ /* ... otherwise match the first one in dictionary */
@ -326,16 +326,12 @@ xbps_find_virtualpkg_in_dict(struct xbps_handle *xhp,
while ((obj = xbps_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
pkgd = xbps_dictionary_get_keysym(d, obj); pkgd = xbps_dictionary_get_keysym(d, obj);
if (xbps_match_virtual_pkg_in_dict(pkgd, pkg, bypattern)) { if (xbps_match_virtual_pkg_in_dict(pkgd, pkg, bypattern)) {
found = true; xbps_object_iterator_release(iter);
break; return pkgd;
} }
} }
xbps_object_iterator_release(iter); xbps_object_iterator_release(iter);
out:
if (found)
return pkgd;
return NULL; return NULL;
} }