From 3405866ae2be30807e1c1e28be33c2dbea3c3641 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 30 Jan 2014 17:47:59 +0100 Subject: [PATCH] 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. --- lib/repo_pkgdeps.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/repo_pkgdeps.c b/lib/repo_pkgdeps.c index 2103c4b5..4003dfba 100644 --- a/lib/repo_pkgdeps.c +++ b/lib/repo_pkgdeps.c @@ -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";