Fix memleak in rpmtsAddInstallElement()
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 22 Oct 2008 06:25:30 +0000 (09:25 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 22 Oct 2008 06:25:30 +0000 (09:25 +0300)
- previously any of the "skipping/replacing already added" checks matching
  would leak memory due to early jump to exit

lib/depends.c

index 58aff31..6d7f35f 100644 (file)
@@ -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;
 }