Fix mdb_env_close(unopened MDB_env).

Do not try to scan me_dbxs in a closed/never-opened MDB_env.
Broken by 7d643d3acb
and 151c416b46.
vmware
Hallvard Furuseth 12 years ago
parent 0b9a208530
commit 521fdb00cc
  1. 10
      libraries/liblmdb/mdb.c

@ -3548,7 +3548,7 @@ leave:
return rc; return rc;
} }
/** Destroy resources from mdb_env_open() and clear our readers */ /** Destroy resources from mdb_env_open(), clear our readers & DBIs */
static void static void
mdb_env_close0(MDB_env *env, int excl) mdb_env_close0(MDB_env *env, int excl)
{ {
@ -3557,6 +3557,10 @@ mdb_env_close0(MDB_env *env, int excl)
if (!(env->me_flags & MDB_ENV_ACTIVE)) if (!(env->me_flags & MDB_ENV_ACTIVE))
return; 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);
free(env->me_dbflags); free(env->me_dbflags);
free(env->me_dbxs); free(env->me_dbxs);
free(env->me_path); free(env->me_path);
@ -3764,14 +3768,10 @@ void
mdb_env_close(MDB_env *env) mdb_env_close(MDB_env *env)
{ {
MDB_page *dp; MDB_page *dp;
int i;
if (env == NULL) if (env == NULL)
return; return;
for (i = env->me_maxdbs; --i > MAIN_DBI; )
free(env->me_dbxs[i].md_name.mv_data);
VGMEMP_DESTROY(env); VGMEMP_DESTROY(env);
while ((dp = env->me_dpages) != NULL) { while ((dp = env->me_dpages) != NULL) {
VGMEMP_DEFINED(&dp->mp_next, sizeof(dp->mp_next)); VGMEMP_DEFINED(&dp->mp_next, sizeof(dp->mp_next));

Loading…
Cancel
Save