teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone
Blob Blame History Raw
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;