From: Howard Chu Date: Thu, 2 Oct 2014 21:11:43 +0000 (+0100) Subject: ITS#7956 fix compact of empty env X-Git-Tag: LMDB_0.9.15~59 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=98ed192949fcc3f0861c68a694dd5e1c0add14f4;p=openldap ITS#7956 fix compact of empty env --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index a7659a5b3c..cfa24bf0db 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -8589,8 +8589,12 @@ mdb_env_copyfd1(MDB_env *env, HANDLE fd) /* Set metapage 1 */ mm->mm_last_pg = txn->mt_next_pgno - freecount - 1; mm->mm_dbs[1] = txn->mt_dbs[1]; - mm->mm_dbs[1].md_root = mm->mm_last_pg; - mm->mm_txnid = 1; + if (mm->mm_last_pg > 1) { + mm->mm_dbs[1].md_root = mm->mm_last_pg; + mm->mm_txnid = 1; + } else { + mm->mm_dbs[1].md_root = P_INVALID; + } } my.mc_wlen[0] = env->me_psize * 2; my.mc_txn = txn;