From 595f9e700d17d6269b5a8cf5ecc643cb927d88aa Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Wed, 5 Aug 2015 13:23:30 +0300 Subject: [PATCH] lmdb: fix b-tree walking bug in case empty db. Change-Id: I28c0985493327babe4d2ae5c6cd56116a26e6034 --- mdb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mdb.c b/mdb.c index 66eabeac..a4b68a36 100644 --- a/mdb.c +++ b/mdb.c @@ -9727,6 +9727,10 @@ mdb_env_walk(mdb_walk_ctx_t *ctx, const char* dbi, pgno_t pg, int flags, int dee int rc; unsigned i; + /* Empty DB, nothing to do */ + if (pg == P_INVALID) + return MDB_SUCCESS; + if (deep < 2) { if ((rc = mdb_page_get(ctx->mw_txn, pg, &mp, NULL)) != 0) return rc; @@ -9736,10 +9740,6 @@ mdb_env_walk(mdb_walk_ctx_t *ctx, const char* dbi, pgno_t pg, int flags, int dee return rc; } - /* Empty DB, nothing to do */ - if (pg == P_INVALID) - return MDB_SUCCESS; - mc.mc_snum = 1; mc.mc_top = 0; mc.mc_txn = ctx->mw_txn;