mdbx: fix SIGSEGV/invalid-deref/invalid-free inside env_close() when mdbx_env_open() failed in re-open case.

Thanks to [@leisim](https://t.me/leisim) for [reporting](https://t.me/libmdbx/3946) this issue.
This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2022-11-23 00:57:02 +03:00
parent da023657f5
commit a1333fc827

View File

@ -14280,9 +14280,10 @@ __cold static int env_close(MDBX_env *env) {
} }
if (env->me_dbxs) { if (env->me_dbxs) {
for (size_t i = env->me_numdbs; --i >= CORE_DBS;) for (size_t i = CORE_DBS; i < env->me_numdbs; ++i)
osal_free(env->me_dbxs[i].md_name.iov_base); osal_free(env->me_dbxs[i].md_name.iov_base);
osal_free(env->me_dbxs); osal_free(env->me_dbxs);
env->me_numdbs = CORE_DBS;
env->me_dbxs = nullptr; env->me_dbxs = nullptr;
} }
if (env->me_pbuf) { if (env->me_pbuf) {