From: Matt Caswell Date: Wed, 16 Apr 2025 11:15:51 +0000 (+0100) Subject: Assert that we successfully obtained a lock X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=606de509e3828fd2fb65184500e6197c82a0efcf;p=thirdparty%2Fopenssl.git Assert that we successfully obtained a lock We should never fail to obtain a lock, so assert that we are successful Reviewed-by: Viktor Dukhovni Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27408) --- diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c index 750ef201210..44d6ebe0923 100644 --- a/crypto/threads_pthread.c +++ b/crypto/threads_pthread.c @@ -624,7 +624,7 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void) __owur int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock) { # ifdef USE_RWLOCK - if (pthread_rwlock_rdlock(lock) != 0) + if (!ossl_assert(pthread_rwlock_rdlock(lock) == 0)) return 0; # else if (pthread_mutex_lock(lock) != 0) { @@ -639,7 +639,7 @@ __owur int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock) __owur int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock) { # ifdef USE_RWLOCK - if (pthread_rwlock_wrlock(lock) != 0) + if (!ossl_assert(pthread_rwlock_wrlock(lock) == 0)) return 0; # else if (pthread_mutex_lock(lock) != 0) {