From c7db955a94344b028ffba506bea1b5c2ecd564ca Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Sat, 16 Feb 2013 19:08:37 +0100 Subject: [PATCH] ITS#7517 Don't save dropped dirty MDB databases. mdb_txn_commit's attempt to save the DB could corrupt another DB if another thread had called mdb_dbi_open and reused the closed DBI. --- libraries/liblmdb/mdb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 40b9bda484..715d1c811a 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -7146,8 +7146,10 @@ int mdb_drop(MDB_txn *txn, MDB_dbi dbi, int del) /* Can't delete the main DB */ if (del && dbi > MAIN_DBI) { rc = mdb_del(txn, MAIN_DBI, &mc->mc_dbx->md_name, NULL); - if (!rc) + if (!rc) { + txn->mt_dbflags[dbi] = DB_STALE; mdb_dbi_close(txn->mt_env, dbi); + } } else { /* reset the DB record, mark it dirty */ txn->mt_dbflags[dbi] |= DB_DIRTY; -- 2.39.5