xbps-pkgdb: fix use-after-free introduced in 3855d2e.

This commit is contained in:
Juan RP 2015-02-23 08:26:20 +01:00
parent 3855d2e2fb
commit b909e8edc3

View File

@ -95,16 +95,17 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
xbps_dictionary_get_cstring_nocopy(obj, xbps_dictionary_get_cstring_nocopy(obj,
"sha256", &sha256); "sha256", &sha256);
rv = xbps_file_hash_check(path, sha256); rv = xbps_file_hash_check(path, sha256);
free(path);
switch (rv) { switch (rv) {
case 0: case 0:
if (check_file_mtime(obj, pkgname, path)) { if (check_file_mtime(obj, pkgname, path)) {
test_broken = true; test_broken = true;
} }
free(path);
break; break;
case ENOENT: case ENOENT:
xbps_error_printf("%s: unexistent file %s.\n", xbps_error_printf("%s: unexistent file %s.\n",
pkgname, file); pkgname, file);
free(path);
test_broken = true; test_broken = true;
break; break;
case ERANGE: case ERANGE:
@ -116,11 +117,13 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
"for %s.\n", pkgname, file); "for %s.\n", pkgname, file);
test_broken = true; test_broken = true;
} }
free(path);
break; break;
default: default:
xbps_error_printf( xbps_error_printf(
"%s: can't check `%s' (%s)\n", "%s: can't check `%s' (%s)\n",
pkgname, file, strerror(rv)); pkgname, file, strerror(rv));
free(path);
break; break;
} }
} }