]> git.sur5r.net Git - openldap/commitdiff
ITS#7956 fix compact of empty env
authorHoward Chu <hyc@symas.com>
Thu, 2 Oct 2014 21:11:43 +0000 (22:11 +0100)
committerHallvard Furuseth <hallvard@openldap.org>
Mon, 1 Dec 2014 19:15:36 +0000 (20:15 +0100)
libraries/liblmdb/mdb.c

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