summaryrefslogtreecommitdiff
path: root/crypto/threads_pthread.c
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-10-03 15:23:05 +0200
committerPauli <pauli@openssl.org>2022-10-05 10:20:10 +1100
commit894f2166ef2c16d8e4533e1c09e05ff31ea2f1d8 (patch)
tree1c74625f8bf9e9dd3642793cabe26cddead10050 /crypto/threads_pthread.c
parented49476a16b8ff2688a53a2ba7e011e6911620f8 (diff)
downloadopenssl-new-894f2166ef2c16d8e4533e1c09e05ff31ea2f1d8.tar.gz
CRYPTO_THREAD_lock_new(): Avoid infinite recursion on allocation error
Fixes #19334 Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19335)
Diffstat (limited to 'crypto/threads_pthread.c')
-rw-r--r--crypto/threads_pthread.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c
index bfc05a4e87..4aeba50479 100644
--- a/crypto/threads_pthread.c
+++ b/crypto/threads_pthread.c
@@ -47,10 +47,9 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
# ifdef USE_RWLOCK
CRYPTO_RWLOCK *lock;
- if ((lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t))) == NULL) {
+ if ((lock = CRYPTO_zalloc(sizeof(pthread_rwlock_t), NULL, 0)) == NULL)
/* Don't set error, to avoid recursion blowup. */
return NULL;
- }
if (pthread_rwlock_init(lock, NULL) != 0) {
OPENSSL_free(lock);
@@ -60,10 +59,9 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
pthread_mutexattr_t attr;
CRYPTO_RWLOCK *lock;
- if ((lock = OPENSSL_zalloc(sizeof(pthread_mutex_t))) == NULL) {
+ if ((lock = CRYPTO_zalloc(sizeof(pthread_mutex_t), NULL, 0)) == NULL)
/* Don't set error, to avoid recursion blowup. */
return NULL;
- }
/*
* We don't use recursive mutexes, but try to catch errors if we do.