From cf89739282feadb36ef50d0b8d8c4e293cd0c24c Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 22 Oct 2008 09:25:30 +0300 Subject: [PATCH] Fix memleak in rpmtsAddInstallElement() - previously any of the "skipping/replacing already added" checks matching would leak memory due to early jump to exit --- lib/depends.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/depends.c b/lib/depends.c index 58aff31..6d7f35f 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -118,7 +118,7 @@ int rpmtsAddInstallElement(rpmts ts, Header h, struct rpmtd_s td; const char * arch = NULL; const char * os = NULL; - rpmds oldChk, newChk; + rpmds oldChk = NULL, newChk = NULL; rpmds obsoletes; rpmalKey pkgKey; /* addedPackages key */ int xx; @@ -216,8 +216,6 @@ int rpmtsAddInstallElement(rpmts ts, Header h, } } pi = rpmtsiFree(pi); - oldChk = rpmdsFree(oldChk); - newChk = rpmdsFree(newChk); /* If newer NEVR was already added, exit now. */ if (ec) @@ -353,6 +351,8 @@ addheader: ec = 0; exit: + oldChk = rpmdsFree(oldChk); + newChk = rpmdsFree(newChk); pi = rpmtsiFree(pi); return ec; } -- 2.7.4