rpm/rpm-4.9.0-beta1-index-iteration.patch
Panu Matilainen f3f6be5ff3 - avoid division by zero in rpmdb size calculation (#671056)
- fix secondary index iteration returing duplicate at end (#671149)
- fix rebuilddb creating duplicate indexes for first header
2011-01-21 14:07:30 +02:00

26 lines
1.0 KiB
Diff

commit a3ec6066af23e0c9e0de6160c14cb2a502e8fa89
Author: Panu Matilainen <pmatilai@redhat.com>
Date: Fri Jan 21 13:52:17 2011 +0200
Fix rpmdb index match iteration termination with NULL keyp (#671149)
- When iterating secondary indexes with NULL keyp, the last entry
was being returned twice as dbiAppendSet() would get called
even when dbiGet() returned non-zero.
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index e58de35..dc6d7a7 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -2048,10 +2048,9 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, rpmDbiTagVal rpmtag,
/* get all entries from index */
xx = dbiCopen(dbi, &dbcursor, 0);
- while (rc==0) {
+ while ((rc = dbiGet(dbi, dbcursor, &key, &data, DB_NEXT)) == 0) {
dbiIndexSet newset = NULL;
- rc = dbiGet(dbi, dbcursor, &key, &data, DB_NEXT);
(void) dbt2set(dbi, &data, &newset);
if (set == NULL) {
set = newset;