Fix rpmdb index match iteration termination with NULL keyp (#671149)
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 21 Jan 2011 11:52:17 +0000 (13:52 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 21 Jan 2011 11:52:17 +0000 (13:52 +0200)
- 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.

lib/rpmdb.c

index e58de35..dc6d7a7 100644 (file)
@@ -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;