GH773: Possible leak on CRYPTO_THREAD_lock_new failure

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
This commit is contained in:
FdaSilvaYY 2016-03-01 21:59:48 +01:00 committed by Rich Salz
parent e257b2c2ae
commit 0b2fc9286f
2 changed files with 6 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;
}