Plug a memleak on erasure
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 3 Jul 2008 14:01:52 +0000 (17:01 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 3 Jul 2008 14:01:52 +0000 (17:01 +0300)
- on erasure the order of things in ts->order is reverse from that of
  rpmtsi-iteration, causing rpmtsiNext() to abort earlier than it should
  when things are removed underneath it
- just walk the ts->order table without iteration, it doesn't make any
  difference here

lib/rpmts.c

index 603914a..6c0deab 100644 (file)
@@ -811,18 +811,14 @@ void rpmtsClean(rpmts ts)
 
 void rpmtsEmpty(rpmts ts)
 {
-    rpmtsi pi; rpmte p;
-    int oc;
-
     if (ts == NULL)
        return;
 
     rpmtsClean(ts);
 
-    for (pi = rpmtsiInit(ts), oc = 0; (p = rpmtsiNext(pi, 0)) != NULL; oc++) {
+    for (int oc = 0; oc < ts->orderCount; oc++) {
        ts->order[oc] = rpmteFree(ts->order[oc]);
     }
-    pi = rpmtsiFree(pi);
 
     ts->orderCount = 0;
     ts->ntrees = 0;