mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
Fix the error handling in ERR_get_state:
- Ignoring the return code of ossl_init_thread_start created a memory leak. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3712)
This commit is contained in:
parent
9b579777c5
commit
af6de400b4
@ -642,7 +642,7 @@ const char *ERR_reason_error_string(unsigned long e)
|
||||
|
||||
void err_delete_thread_state(void)
|
||||
{
|
||||
ERR_STATE *state = ERR_get_state();
|
||||
ERR_STATE *state = CRYPTO_THREAD_get_local(&err_thread_local);
|
||||
if (state == NULL)
|
||||
return;
|
||||
|
||||
@ -682,14 +682,14 @@ ERR_STATE *ERR_get_state(void)
|
||||
if (state == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!CRYPTO_THREAD_set_local(&err_thread_local, state)) {
|
||||
if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)
|
||||
|| !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
|
||||
ERR_STATE_free(state);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Ignore failures from these */
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
|
||||
ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE);
|
||||
}
|
||||
|
||||
return state;
|
||||
|
Loading…
Reference in New Issue
Block a user