diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c index 2b32e142ae091a80980f2fed11a88bee6612c499..edca77c0b972a207bb1b866ae8723225302bb70d 100644 --- a/crypto/threads_pthread.c +++ b/crypto/threads_pthread.c @@ -58,8 +58,10 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void) if (lock == NULL) return NULL; - if (pthread_rwlock_init(lock, NULL) != 0) + if (pthread_rwlock_init(lock, NULL) != 0) { + OPENSSL_free(lock); return NULL; + } return lock; } diff --git a/crypto/threads_win.c b/crypto/threads_win.c index bee628ff8196597bba03d8c2a7d873935529beef..741e8f827e97b946b8c1d87502927083c5895a20 100644 --- a/crypto/threads_win.c +++ b/crypto/threads_win.c @@ -59,8 +59,10 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void) return NULL; /* 0x400 is the spin count value suggested in the documentation */ - if (!InitializeCriticalSectionAndSpinCount(lock, 0x400)) + if (!InitializeCriticalSectionAndSpinCount(lock, 0x400)) { + OPENSSL_free(lock); return NULL; + } return lock; }