[pacman-dev] [PATCH 1/3] libalpm: correctly load signatures for package files

Rémy Oudompheng remyoudompheng at gmail.com
Sun Apr 10 07:25:23 EDT 2011


A duplicate _alpm_pkg_new() call made libalpm load the signature
in a separate pmpkg_t that was leaked forever afterwards.

Signed-off-by: Rémy Oudompheng <remy at archlinux.org>
---
This patch make the signatures for local files load
correctly.

On branch 'master'

 lib/libalpm/be_package.c |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index a693247..d87d539 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -251,15 +251,16 @@ static pmpkg_t *pkg_load(const char *pkgfile, int full)
 		RET_ERR(PM_ERR_WRONG_ARGS, NULL);
 	}
 
+	newpkg = _alpm_pkg_new();
+	if(newpkg == NULL) {
+		RET_ERR(PM_ERR_MEMORY, NULL);
+	}
+
 	/* attempt to stat the package file, ensure it exists */
 	if(stat(pkgfile, &st) == 0) {
 		char *pgpfile;
 		int sig_ret;
 
-		newpkg = _alpm_pkg_new();
-		if(newpkg == NULL) {
-			RET_ERR(PM_ERR_MEMORY, NULL);
-		}
 		newpkg->filename = strdup(pkgfile);
 		newpkg->size = st.st_size;
 
@@ -289,15 +290,6 @@ static pmpkg_t *pkg_load(const char *pkgfile, int full)
 		RET_ERR(PM_ERR_PKG_OPEN, NULL);
 	}
 
-	newpkg = _alpm_pkg_new();
-	if(newpkg == NULL) {
-		archive_read_finish(archive);
-		RET_ERR(PM_ERR_MEMORY, NULL);
-	}
-
-	newpkg->filename = strdup(pkgfile);
-	newpkg->size = st.st_size;
-
 	_alpm_log(PM_LOG_DEBUG, "starting package load for %s\n", pkgfile);
 
 	/* If full is false, only read through the archive until we find our needed
-- 
1.7.4.4



More information about the pacman-dev mailing list