From 77bdbdd9de439224261c57bdcaf4d3281885f928 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Wed, 20 May 2015 03:17:47 +0200 Subject: [PATCH] mtest*.c: Fix MDB_NOOVERWRITE, plug cursor leak --- libraries/liblmdb/mtest.c | 6 ++++-- libraries/liblmdb/mtest2.c | 4 ++-- libraries/liblmdb/mtest6.c | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libraries/liblmdb/mtest.c b/libraries/liblmdb/mtest.c index 7efa8b5..9d15088 100644 --- a/libraries/liblmdb/mtest.c +++ b/libraries/liblmdb/mtest.c @@ -54,12 +54,13 @@ int main(int argc,char * argv[]) key.mv_size = sizeof(int); key.mv_data = sval; - data.mv_size = sizeof(sval); - data.mv_data = sval; printf("Adding %d values\n", count); for (i=0;i in each iteration, since MDB_NOOVERWRITE may modify it */ + data.mv_size = sizeof(sval); + data.mv_data = sval; if (RES(MDB_KEYEXIST, mdb_put(txn, dbi, &key, &data, MDB_NOOVERWRITE))) { j++; data.mv_size = sizeof(sval); @@ -130,6 +131,7 @@ int main(int argc,char * argv[]) (int) key.mv_size, (char *) key.mv_data, (int) data.mv_size, (char *) data.mv_data); + mdb_cursor_close(cursor); mdb_txn_abort(txn); printf("Deleting with cursor\n"); diff --git a/libraries/liblmdb/mtest2.c b/libraries/liblmdb/mtest2.c index cc6ecf6..eacbe59 100644 --- a/libraries/liblmdb/mtest2.c +++ b/libraries/liblmdb/mtest2.c @@ -57,12 +57,12 @@ int main(int argc,char * argv[]) key.mv_size = sizeof(int); key.mv_data = sval; - data.mv_size = sizeof(sval); - data.mv_data = sval; printf("Adding %d values\n", count); for (i=0;i