From: Panu Matilainen Date: Wed, 22 Oct 2008 06:25:30 +0000 (+0300) Subject: Fix memleak in rpmtsAddInstallElement() X-Git-Tag: tznext/4.11.0.1.tizen20130304~3538 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf89739282feadb36ef50d0b8d8c4e293cd0c24c;p=tools%2Flibrpm-tizen.git Fix memleak in rpmtsAddInstallElement() - previously any of the "skipping/replacing already added" checks matching would leak memory due to early jump to exit --- 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; }