[pacman-dev] [PATCH 4/4] lib/libalpm/util.c: Fix two memory leaks

Lukas Fleischer archlinux at cryptocrack.de
Fri Aug 26 07:10:38 EDT 2011


Free "md5sum" if md5_file() fails in alpm_compute_md5sum(). Free
"sha256sum" if sha2_file() fails in alpm_compute_sha256sum().

Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
---
 lib/libalpm/util.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 7e3bc37..3d1f9d5 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -831,6 +831,7 @@ char SYMEXPORT *alpm_compute_md5sum(const char *filename)
 	ret = md5_file(filename, output);
 
 	if(ret > 0) {
+		free(md5sum);
 		return NULL;
 	}
 
@@ -862,6 +863,7 @@ char SYMEXPORT *alpm_compute_sha256sum(const char *filename)
 	ret = sha2_file(filename, output, 0);
 
 	if(ret > 0) {
+		free(sha256sum);
 		return NULL;
 	}
 
-- 
1.7.6.1



More information about the pacman-dev mailing list