From c6e010a872546c82f8a4280c954c985e8fbe2053 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Sat, 31 Oct 2015 13:56:12 +0300 Subject: [PATCH] mdbx: fix segfault on close when open failed. --- mdb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mdb.c b/mdb.c index e4f45e6b..5e66e0a9 100644 --- a/mdb.c +++ b/mdb.c @@ -4899,6 +4899,7 @@ mdb_env_close0(MDB_env *env) mdb_coherent_barrier(); mdb_ensure(env, pthread_mutex_unlock(&mdb_rthc_lock) == 0); munmap((void *)env->me_txns, (env->me_maxreaders-1)*sizeof(MDB_reader)+sizeof(MDB_txninfo)); + env->me_txns = NULL; if (env->me_lfd != INVALID_HANDLE_VALUE) { (void) close(env->me_lfd); @@ -4921,7 +4922,7 @@ mdbx_env_close_ex(MDB_env *env, int dont_sync) if (unlikely(env->me_signature != MDBX_ME_SIGNATURE)) return MDB_VERSION_MISMATCH; - if (! dont_sync) + if (! dont_sync && env->me_txns) rc = mdb_env_sync(env, 1); VALGRIND_DESTROY_MEMPOOL(env);