summaryrefslogtreecommitdiffstats
path: root/crypto/threads_pthread.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2018-04-05 15:13:55 -0400
committerRich Salz <rsalz@openssl.org>2018-04-05 15:13:55 -0400
commit7de2b9c4afd90359e47d81a5fa70bcb8506fbf91 (patch)
tree6dd747cfc308dcae60f4aaf7e8ba354073e8413b /crypto/threads_pthread.c
parent77579510aa40aa769ceafc7a0c856381800e79c2 (diff)
Set error code if alloc returns NULL
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5886)
Diffstat (limited to 'crypto/threads_pthread.c')
-rw-r--r--crypto/threads_pthread.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c
index 3aeef21668..a2c1707865 100644
--- a/crypto/threads_pthread.c
+++ b/crypto/threads_pthread.c
@@ -19,9 +19,12 @@
CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
{
# ifdef USE_RWLOCK
- CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
- if (lock == NULL)
+ CRYPTO_RWLOCK *lock;
+
+ if ((lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t))) == NULL) {
+ /* Don't set error, to avoid recursion blowup. */
return NULL;
+ }
if (pthread_rwlock_init(lock, NULL) != 0) {
OPENSSL_free(lock);
@@ -29,9 +32,12 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
}
# else
pthread_mutexattr_t attr;
- CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_mutex_t));
- if (lock == NULL)
+ CRYPTO_RWLOCK *lock;
+
+ if ((lock = OPENSSL_zalloc(sizeof(pthread_mutex_t))) == NULL) {
+ /* Don't set error, to avoid recursion blowup. */
return NULL;
+ }
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);