From b909e8edc38d1e563ae9c10374d2becc8477c290 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 23 Feb 2015 08:26:20 +0100 Subject: [PATCH] xbps-pkgdb: fix use-after-free introduced in 3855d2e. --- bin/xbps-pkgdb/check_pkg_files.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/xbps-pkgdb/check_pkg_files.c b/bin/xbps-pkgdb/check_pkg_files.c index 6e4ad149..2d3d1a92 100644 --- a/bin/xbps-pkgdb/check_pkg_files.c +++ b/bin/xbps-pkgdb/check_pkg_files.c @@ -95,16 +95,17 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg) xbps_dictionary_get_cstring_nocopy(obj, "sha256", &sha256); rv = xbps_file_hash_check(path, sha256); - free(path); switch (rv) { case 0: if (check_file_mtime(obj, pkgname, path)) { test_broken = true; } + free(path); break; case ENOENT: xbps_error_printf("%s: unexistent file %s.\n", pkgname, file); + free(path); test_broken = true; break; case ERANGE: @@ -116,11 +117,13 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg) "for %s.\n", pkgname, file); test_broken = true; } + free(path); break; default: xbps_error_printf( "%s: can't check `%s' (%s)\n", pkgname, file, strerror(rv)); + free(path); break; } }