summaryrefslogtreecommitdiff
path: root/lib/transaction.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-05-30 11:45:41 +0300
committerPanu Matilainen <pmatilai@redhat.com>2011-05-30 11:45:41 +0300
commite996d917eec167d12f158af7156ebc8c40825a8f (patch)
tree9e513a3c9e3183b479d0f0cb3d0e70f531c94500 /lib/transaction.c
parent50435cefaaaa2401fc4022292ffb98d9c1ef92fd (diff)
downloadrpm-e996d917eec167d12f158af7156ebc8c40825a8f.tar.gz
rpm-e996d917eec167d12f158af7156ebc8c40825a8f.tar.bz2
rpm-e996d917eec167d12f158af7156ebc8c40825a8f.zip
Remove possibility of abusing freed iterator by moving to local scope
- Eliminates another dead NULL-assignment + makes it "safer"
Diffstat (limited to 'lib/transaction.c')
-rw-r--r--lib/transaction.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/transaction.c b/lib/transaction.c
index 3f1bc0fce..a6794e45a 100644
--- a/lib/transaction.c
+++ b/lib/transaction.c
@@ -1037,7 +1037,6 @@ static rpmps checkProblems(rpmts ts)
/* XXX Only added packages need be checked. */
rpmlog(RPMLOG_DEBUG, "sanity checking %d elements\n", rpmtsNElements(ts));
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
- rpmdbMatchIterator mi;
if (!(probFilter & RPMPROB_FILTER_IGNOREARCH) && badArch(rpmteA(p)))
rpmteAddProblem(p, RPMPROB_BADARCH, rpmteA(p), NULL, 0);
@@ -1047,14 +1046,16 @@ static rpmps checkProblems(rpmts ts)
if (!(probFilter & RPMPROB_FILTER_OLDPACKAGE)) {
Header h;
+ rpmdbMatchIterator mi;
mi = rpmtsInitIterator(ts, RPMDBI_NAME, rpmteN(p), 0);
while ((h = rpmdbNextIterator(mi)) != NULL)
ensureOlder(p, h);
- mi = rpmdbFreeIterator(mi);
+ rpmdbFreeIterator(mi);
}
if (!(probFilter & RPMPROB_FILTER_REPLACEPKG)) {
Header h;
+ rpmdbMatchIterator mi;
mi = rpmtsInitIterator(ts, RPMDBI_NAME, rpmteN(p), 0);
rpmdbSetIteratorRE(mi, RPMTAG_EPOCH, RPMMIRE_STRCMP, rpmteE(p));
rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_STRCMP, rpmteV(p));
@@ -1068,7 +1069,7 @@ static rpmps checkProblems(rpmts ts)
rpmteAddProblem(p, RPMPROB_PKG_INSTALLED, NULL, NULL,
headerGetInstance(h));
}
- mi = rpmdbFreeIterator(mi);
+ rpmdbFreeIterator(mi);
}
}
rpmtsiFree(pi);