lib/repo_pkgdeps.c: check correctly for errno after our call, not after free(3).

The issue was that xbps_pkgdb_get_pkg() did not find any package,
and the code was free(3)ing heap allocated memory before checking for
errno. I suspect that free(3) has touched errno and this errno value
has been propagated to the next code.

Found after a bit of testing on repo.voidlinux.eu.
This commit is contained in:
Juan RP 2014-01-30 17:47:59 +01:00
parent 9b68cbe079
commit 3405866ae2

View File

@ -196,15 +196,16 @@ find_repo_deps(struct xbps_handle *xhp,
*/
if (((tmpd = xbps_pkgdb_get_pkg(xhp, pkgname)) == NULL) &&
((tmpd = xbps_pkgdb_get_virtualpkg(xhp, pkgname)) == NULL)) {
free(pkgname);
if (errno && errno != ENOENT) {
/* error */
rv = errno;
xbps_dbg_printf(xhp, "failed to find "
"installed pkg for `%s': %s\n",
reqpkg, strerror(errno));
free(pkgname);
break;
}
free(pkgname);
/* Required pkgdep not installed */
xbps_dbg_printf_append(xhp, "not installed ");
reason = "install";