aboutsummaryrefslogtreecommitdiff
path: root/crypto/ex_data.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-07-19 19:42:11 +0200
committerRichard Levitte <levitte@openssl.org>2016-07-19 23:49:54 +0200
commitc2e4e5d248567d4eea5bf6d525bdbcc09099ba6e (patch)
treee4e16df15de0263a21427c92ae21d20dc98e3c19 /crypto/ex_data.c
parent925d17f3ee4b7f7881fa77a31524ecd9f1305242 (diff)
downloadopenssl-c2e4e5d248567d4eea5bf6d525bdbcc09099ba6e.zip
openssl-c2e4e5d248567d4eea5bf6d525bdbcc09099ba6e.tar.gz
openssl-c2e4e5d248567d4eea5bf6d525bdbcc09099ba6e.tar.bz2
Change all our uses of CRYPTO_THREAD_run_once to use RUN_ONCE instead
That way, we have a way to check if the init function was successful or not. Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'crypto/ex_data.c')
-rw-r--r--crypto/ex_data.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/crypto/ex_data.c b/crypto/ex_data.c
index 0666393..d9807d5 100644
--- a/crypto/ex_data.c
+++ b/crypto/ex_data.c
@@ -8,6 +8,7 @@
*/
#include "internal/cryptlib_int.h"
+#include "internal/thread_once.h"
#include <openssl/lhash.h>
/*
@@ -35,9 +36,10 @@ static EX_CALLBACKS ex_data[CRYPTO_EX_INDEX__COUNT];
static CRYPTO_RWLOCK *ex_data_lock = NULL;
static CRYPTO_ONCE ex_data_init = CRYPTO_ONCE_STATIC_INIT;
-static void do_ex_data_init(void)
+DEFINE_RUN_ONCE_STATIC(do_ex_data_init)
{
ex_data_lock = CRYPTO_THREAD_lock_new();
+ return ex_data_lock != NULL;
}
/*
@@ -53,7 +55,10 @@ static EX_CALLBACKS *get_and_lock(int class_index)
return NULL;
}
- CRYPTO_THREAD_run_once(&ex_data_init, do_ex_data_init);
+ if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
+ CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
+ return NULL;
+ }
if (ex_data_lock == NULL) {
/*