From c0575825730dd2aab4031100b25d632a3d052447 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 20 Apr 2013 19:30:06 -0700 Subject: [PATCH] Fix MDB_LAST, reset cursor index --- libraries/liblmdb/mdb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index d3bb4da8ce..30475ac7e5 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -4705,19 +4705,19 @@ mdb_cursor_last(MDB_cursor *mc, MDB_val *key, MDB_val *data) if (!(mc->mc_flags & C_EOF)) { - if (!(mc->mc_flags & C_INITIALIZED) || mc->mc_top) { - MDB_val lkey; + if (!(mc->mc_flags & C_INITIALIZED) || mc->mc_top) { + MDB_val lkey; - lkey.mv_size = MDB_MAXKEYSIZE+1; - lkey.mv_data = NULL; - rc = mdb_page_search(mc, &lkey, 0); - if (rc != MDB_SUCCESS) - return rc; - } - assert(IS_LEAF(mc->mc_pg[mc->mc_top])); + lkey.mv_size = MDB_MAXKEYSIZE+1; + lkey.mv_data = NULL; + rc = mdb_page_search(mc, &lkey, 0); + if (rc != MDB_SUCCESS) + return rc; + } + assert(IS_LEAF(mc->mc_pg[mc->mc_top])); - mc->mc_ki[mc->mc_top] = NUMKEYS(mc->mc_pg[mc->mc_top]) - 1; } + mc->mc_ki[mc->mc_top] = NUMKEYS(mc->mc_pg[mc->mc_top]) - 1; mc->mc_flags |= C_INITIALIZED|C_EOF; leaf = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]); -- 2.39.5