lmdb: fix segfault in mdb_chk when mdb_env_open() failed.

Change-Id: If72d35518c2d4dd33d284049e00fc633e65ee52c
This commit is contained in:
Leo Yuriev 2015-08-07 22:39:57 +03:00
parent 65555273aa
commit ad8c4a19bb
2 changed files with 7 additions and 2 deletions

6
mdb.c
View File

@ -2575,8 +2575,12 @@ mdb_env_sync(MDB_env *env, int force)
int rc;
pthread_mutex_t *mutex;
MDB_meta *head;
unsigned flags = env->me_flags & ~MDB_NOMETASYNC;
unsigned flags;
if (unlikely(! env || ! env->me_txns))
return EINVAL;
flags = env->me_flags & ~MDB_NOMETASYNC;
if (unlikely(flags & (MDB_RDONLY | MDB_FATAL_ERROR)))
return EACCES;

View File

@ -755,7 +755,8 @@ bailout:
mdb_txn_abort(txn);
if (locktxn)
mdb_txn_abort(locktxn);
mdb_env_close(env);
if (env)
mdb_env_close(env);
free(pagemap);
if (rc)
return EXIT_FAILURE + 2;