Fix endless loop on RPMDBI_PACKAGES iteration when offset specified
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 22 Sep 2009 11:52:57 +0000 (14:52 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 22 Sep 2009 11:52:57 +0000 (14:52 +0300)
lib/rpmdb.c

index f15c446..f6028e1 100644 (file)
@@ -2038,8 +2038,10 @@ top:
     } while (mi->mi_offset == 0);
 
     /* If next header is identical, return it now. */
-    if (mi->mi_prevoffset && mi->mi_offset == mi->mi_prevoffset)
-       return mi->mi_h;
+    if (mi->mi_prevoffset && mi->mi_offset == mi->mi_prevoffset) {
+       /* ...but rpmdb record numbers are unique, avoid endless loop */
+       return (mi->mi_rpmtag == RPMDBI_PACKAGES) ? NULL : mi->mi_h;
+    }
 
     /* Retrieve next header blob for index iterator. */
     if (uh == NULL) {