From 24a8bdec49ee360bf0412631ff8931de91e109fc Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Wed, 20 Dec 2017 14:22:37 +0300 Subject: [PATCH] mdbx: fix SIGSEGV in case mdbx_env_close_ex() called without mdbx_env_open(). --- src/mdbx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mdbx.c b/src/mdbx.c index 6d25c03d..3d435ca2 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -5387,8 +5387,9 @@ int __cold mdbx_env_close_ex(MDBX_env *env, int dont_sync) { if (unlikely(env->me_signature != MDBX_ME_SIGNATURE)) return MDBX_EBADSIGN; - if ((env->me_flags & MDBX_RDONLY) == 0) { - if (env->me_txn0->mt_owner && env->me_txn0->mt_owner != mdbx_thread_self()) + if (env->me_lck && (env->me_flags & MDBX_RDONLY) == 0) { + if (env->me_txn0 && env->me_txn0->mt_owner && + env->me_txn0->mt_owner != mdbx_thread_self()) return MDBX_BUSY; if (!dont_sync) rc = mdbx_env_sync(env, true);