summaryrefslogtreecommitdiffstats
path: root/crypto/err
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2017-06-19 11:18:44 +0200
committerRich Salz <rsalz@openssl.org>2017-06-19 09:25:26 -0400
commit77b072504ec464eac5e0f9aab19cadb9c4e311d1 (patch)
tree9607779b271291a6785f270f72bd7a12b5f6d792 /crypto/err
parent0e0a9ae30baff1c886200f4ee682f893ec8eda30 (diff)
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) (cherry picked from commit af6de400b49c011600cfd557319d1142da6e5cbd)
Diffstat (limited to 'crypto/err')
-rw-r--r--crypto/err/err.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c
index 8b47085516..57b9576ea6 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -625,7 +625,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;
@@ -665,14 +665,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;