Commit 0b2fc928 authored by FdaSilvaYY's avatar FdaSilvaYY Committed by Rich Salz
Browse files

GH773: Possible leak on CRYPTO_THREAD_lock_new failure



Signed-off-by: default avatarRich Salz <rsalz@akamai.com>
Reviewed-by: default avatarMatt Caswell <matt@openssl.org>
parent e257b2c2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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;
}
+3 −1
Original line number Diff line number Diff line
@@ -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;
}