Call CONF_modules_free() before ENGINE_cleanup() in auto-deinit

During auto de-init we were calling ENGINE_cleanup(), and then later
CONF_modules_free(). However the latter function can end up calling
engine code, which can lead to a use of the global_engine_lock after it
has already been freed. Therefore we should swap the calling order of
these two functions.

Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
Matt Caswell 2016-03-11 09:52:52 +00:00
parent 71627423e5
commit 773fd0bad4

View File

@ -468,13 +468,13 @@ void OPENSSL_cleanup(void)
fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: "
"RAND_cleanup()\n");
#endif
#ifndef OPENSSL_NO_ENGINE
ENGINE_cleanup();
#endif
CRYPTO_cleanup_all_ex_data();
EVP_cleanup();
CONF_modules_free();
#ifndef OPENSSL_NO_ENGINE
ENGINE_cleanup();
#endif
RAND_cleanup();
base_inited = 0;
}