From 204904df7cff07e0f12accc99e374934d3a43ce4 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Tue, 6 Jun 2017 18:28:04 +0300 Subject: [PATCH] mdbx: disallow begin txn if env not yet opened. --- mdbx.h | 2 ++ src/mdbx.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/mdbx.h b/mdbx.h index ec38193c..8d5a6e2e 100644 --- a/mdbx.h +++ b/mdbx.h @@ -79,6 +79,7 @@ typedef DWORD mdbx_tid_t; #define MDBX_EROFS ERROR_FILE_READ_ONLY #define MDBX_ENOSYS ERROR_NOT_SUPPORTED #define MDBX_EIO ERROR_WRITE_FAULT +#define MDBX_EPERM ERROR_INVALID_FUNCTION #else @@ -97,6 +98,7 @@ typedef pthread_t mdbx_tid_t; #define MDBX_EROFS EROFS #define MDBX_ENOSYS ENOSYS #define MDBX_EIO EIO +#define MDBX_EPERM EPERM #endif #ifdef _MSC_VER diff --git a/src/mdbx.c b/src/mdbx.c index 13768b29..417595ad 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -2434,6 +2434,9 @@ int mdbx_txn_begin(MDBX_env *env, MDBX_txn *parent, unsigned flags, return MDBX_PANIC; } + if (unlikely(!env->me_map)) + return MDBX_EPERM; + flags &= MDBX_TXN_BEGIN_FLAGS; flags |= env->me_flags & MDBX_WRITEMAP;