From e7a0c74c099c3003dec91c3b89653656b8fdfd01 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 13 Jan 2015 18:47:18 +0000 Subject: [PATCH] lmdb: Fix potential null deref (coverity). Change-Id: Icc5cadfddecbea81c835d84e4ada785e34638514 --- mdb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mdb.c b/mdb.c index 59f57f2e..d00fb488 100644 --- a/mdb.c +++ b/mdb.c @@ -5185,13 +5185,15 @@ mdb_env_close0(MDB_env *env, int excl) return; /* Doing this here since me_dbxs may not exist during mdb_env_close */ - for (i = env->me_maxdbs; --i > MAIN_DBI; ) - free(env->me_dbxs[i].md_name.mv_data); + if (env->me_dbxs) { + for (i = env->me_maxdbs; --i > MAIN_DBI; ) + free(env->me_dbxs[i].md_name.mv_data); + free(env->me_dbxs); + } free(env->me_pbuf); free(env->me_dbiseqs); free(env->me_dbflags); - free(env->me_dbxs); free(env->me_path); free(env->me_dirty_list); if (env->me_txn0) @@ -7990,7 +7992,7 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst) cdst->mc_ki[cdst->mc_top] = 0; rc = mdb_update_key(cdst, &nullkey); cdst->mc_ki[cdst->mc_top] = ix; - mdb_cassert(csrc, rc == MDB_SUCCESS); + mdb_cassert(cdst, rc == MDB_SUCCESS); } }