teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame rpm-4.9.0-beta1-index-iteration.patch

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