Full_Name: Pietro Cerutti
Version: lmdb 0.9.18
Submission from: (NULL) (184.108.40.206)
mdb_env_stat crashes is the env was created but not opened. This happens because
mdb_env_stat calls mdb_env_pick_meta, which doesn't check whether the two pages
are NULL before dereferencing them.
Please note that there is no mention of the fact that the env must have been
opened before calling mdb_env_stat in the documentation .
The proposed patch is to check whether the environment is active before getting
the most recent page:
--- mdb.c.orig 2016-04-13 10:00:30.084676000 +0000
+"B2B mdb.c 2016-04-13 10:07:32.064085000 +0000
@@ -9432,7 +9432,7 @@
- if (env == NULL || arg == NULL)
+ if (env == NULL || !(env->me_flags & MDB_ENV_ACTIVE) || arg == NULL)
meta = mdb_env_pick_meta(env);