提交 135648bc 编写于 作者: M Matt Caswell

Fix mem leaks during auto-deinit

Certain functions are automatically called during auto-deinit in order
to deallocate resources. However, if we have never entered a function which
marks lib crypto as inited then they never get called. This can happen if
the user only ever makes use of a small sub-set of functions that don't hit
the auto-init code.

This commit ensures all such resources deallocated by these functions also
init libcrypto when they are initially allocated.
Reviewed-by: NRichard Levitte <levitte@openssl.org>
Reviewed-by: NBen Laurie <ben@openssl.org>
上级 2d11f5b2
......@@ -604,6 +604,7 @@ static int addrinfo_wrap(int family, int socktype,
DEFINE_RUN_ONCE_STATIC(do_bio_lookup_init)
{
OPENSSL_init_crypto(0, NULL);
bio_lookup_lock = CRYPTO_THREAD_lock_new();
return bio_lookup_lock != NULL;
}
......
......@@ -18,6 +18,7 @@ CRYPTO_ONCE engine_lock_init = CRYPTO_ONCE_STATIC_INIT;
DEFINE_RUN_ONCE(do_engine_lock_init)
{
OPENSSL_init_crypto(0, NULL);
global_engine_lock = CRYPTO_THREAD_lock_new();
return global_engine_lock != NULL;
}
......
......@@ -251,6 +251,7 @@ static void ERR_STATE_free(ERR_STATE *s)
DEFINE_RUN_ONCE_STATIC(do_err_strings_init)
{
OPENSSL_init_crypto(0, NULL);
err_string_lock = CRYPTO_THREAD_lock_new();
return err_string_lock != NULL;
}
......
......@@ -38,6 +38,7 @@ static CRYPTO_ONCE ex_data_init = CRYPTO_ONCE_STATIC_INIT;
DEFINE_RUN_ONCE_STATIC(do_ex_data_init)
{
OPENSSL_init_crypto(0, NULL);
ex_data_lock = CRYPTO_THREAD_lock_new();
return ex_data_lock != NULL;
}
......
......@@ -89,6 +89,7 @@ static RAND_METHOD rand_meth = {
DEFINE_RUN_ONCE_STATIC(do_rand_lock_init)
{
OPENSSL_init_crypto(0, NULL);
rand_lock = CRYPTO_THREAD_lock_new();
rand_tmp_lock = CRYPTO_THREAD_lock_new();
return rand_lock != NULL && rand_tmp_lock != NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册