From fd054a40b2ba005571455d749de0423975e77651 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Wed, 18 Nov 2020 13:56:14 +0200
Subject: [PATCH] Stop on first failure when trying to open a database
 (RhBug:1898301)

If an index open fails there's no point trying to go on, things are
not going to work and at least BDB will segfault in some cases...

URL:https://github.com/rpm-software-management/rpm/commit/fd054a40b2ba005571455d749de0423975e77651
---
 lib/rpmdb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index 874f079..41da9da 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -355,7 +355,7 @@ static int doOpen(rpmdb db, int justPkgs)
 {
     int rc = pkgdbOpen(db, db->db_flags, NULL);
     if (!justPkgs) {
-	for (int dbix = 0; dbix < db->db_ndbi; dbix++) {
+	for (int dbix = 0; rc == 0 && dbix < db->db_ndbi; dbix++) {
 	    rc += indexOpen(db, db->db_tags[dbix], db->db_flags, NULL);
 	}
     }
-- 
1.8.3.1

