diff --git a/lib/package_conflicts.c b/lib/package_conflicts.c index d66b8b32..8153a016 100644 --- a/lib/package_conflicts.c +++ b/lib/package_conflicts.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2012 Juan Romero Pardines. + * Copyright (c) 2012-2013 Juan Romero Pardines. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,8 +40,8 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkgd; prop_object_t obj; prop_object_iterator_t iter; - const char *cfpkg, *repopkgver, *pkgver, *pkgname, *repopkgname; - char *buf; + const char *cfpkg, *repopkgver, *pkgver; + char *pkgname, *repopkgname, *buf; pkg_cflicts = prop_dictionary_get(pkg_repod, "conflicts"); if (pkg_cflicts == NULL || prop_array_count(pkg_cflicts) == 0) @@ -49,7 +49,8 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, trans_cflicts = prop_dictionary_get(xhp->transd, "conflicts"); prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver); - prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgname", &repopkgname); + repopkgname = xbps_pkg_name(repopkgver); + assert(repopkgname); iter = prop_array_iterator(pkg_cflicts); assert(iter); @@ -62,13 +63,15 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, */ if ((pkgd = xbps_pkgdb_get_pkg(xhp, cfpkg)) || (pkgd = xbps_pkgdb_get_virtualpkg(xhp, cfpkg))) { - prop_dictionary_get_cstring_nocopy(pkgd, - "pkgname", &pkgname); - if (strcmp(pkgname, repopkgname) == 0) - continue; - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + pkgname = xbps_pkg_name(pkgver); + assert(pkgname); + if (strcmp(pkgname, repopkgname) == 0) { + free(pkgname); + continue; + } + free(pkgname); xbps_dbg_printf(xhp, "found conflicting installed " "pkg %s with pkg in transaction %s\n", pkgver, repopkgver); @@ -83,13 +86,15 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, */ if ((pkgd = xbps_find_pkg_in_array(unsorted, cfpkg)) || (pkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, cfpkg))) { - prop_dictionary_get_cstring_nocopy(pkgd, - "pkgname", &pkgname); - if (strcmp(pkgname, repopkgname) == 0) - continue; - prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + pkgname = xbps_pkg_name(pkgver); + assert(pkgname); + if (strcmp(pkgname, repopkgname) == 0) { + free(pkgname); + continue; + } + free(pkgname); xbps_dbg_printf(xhp, "found conflicting pkgs in " "transaction %s <-> %s\n", pkgver, repopkgver); buf = xbps_xasprintf("%s conflicts with " @@ -100,4 +105,5 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, } } prop_object_iterator_release(iter); + free(repopkgname); }