Skip to content

Commit c7b6fa2

Browse files
committed
Return codes and missed srtp.
1 parent 39f632d commit c7b6fa2

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

wolfcrypt/src/wc_port.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3705,7 +3705,7 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
37053705
if (pthread_mutex_init(&cond->mutex, NULL) != 0)
37063706
return MEMORY_E;
37073707
if (pthread_cond_init(&cond->cond, NULL) != 0) {
3708-
pthread_mutex_destroy(&cond->mutex);
3708+
(void)pthread_mutex_destroy(&cond->mutex);
37093709
return MEMORY_E;
37103710
}
37113711
return 0;
@@ -3716,8 +3716,8 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
37163716
if (cond == NULL)
37173717
return BAD_FUNC_ARG;
37183718

3719-
pthread_mutex_destroy(&cond->mutex);
3720-
pthread_cond_destroy(&cond->cond);
3719+
(void)pthread_mutex_destroy(&cond->mutex);
3720+
(void)pthread_cond_destroy(&cond->cond);
37213721
return 0;
37223722
}
37233723

@@ -3726,21 +3726,25 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
37263726
if (cond == NULL)
37273727
return BAD_FUNC_ARG;
37283728

3729-
pthread_mutex_lock(&cond->mutex);
3730-
pthread_cond_signal(&cond->cond);
3731-
pthread_mutex_unlock(&cond->mutex);
3732-
return 0;
3729+
if (pthread_mutex_lock(&cond->mutex) == 0) {
3730+
(void)pthread_cond_signal(&cond->cond);
3731+
(void)pthread_mutex_unlock(&cond->mutex);
3732+
return 0;
3733+
}
3734+
return BAD_MUTEX_E;
37333735
}
37343736

37353737
int wolfSSL_CondWait(COND_TYPE* cond)
37363738
{
37373739
if (cond == NULL)
37383740
return BAD_FUNC_ARG;
37393741

3740-
pthread_mutex_lock(&cond->mutex);
3741-
pthread_cond_wait(&cond->cond, &cond->mutex);
3742-
pthread_mutex_unlock(&cond->mutex);
3743-
return 0;
3742+
if (pthread_mutex_lock(&cond->mutex) == 0) {
3743+
(void)pthread_cond_wait(&cond->cond, &cond->mutex);
3744+
(void)pthread_mutex_unlock(&cond->mutex);
3745+
return 0;
3746+
}
3747+
return BAD_MUTEX_E;
37443748
}
37453749
#else
37463750
/* Apple style dispatch semaphore */

wolfssl/test.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,10 +691,12 @@ static WC_INLINE void srtp_helper_init(srtp_test_helper *srtp)
691691
static WC_INLINE void srtp_helper_get_ekm(srtp_test_helper *srtp,
692692
uint8_t **ekm, size_t *size)
693693
{
694-
if (srtp->server_srtp_ekm == NULL)
695-
THREAD_CHECK_RET(wolfSSL_CondWait(&srtp->cond, &srtp->mutex));
696-
697694
THREAD_CHECK_RET(wc_LockMutex(&srtp->mutex));
695+
if (srtp->server_srtp_ekm == NULL) {
696+
THREAD_CHECK_RET(wc_UnLockMutex(&srtp->mutex));
697+
THREAD_CHECK_RET(wolfSSL_CondWait(&srtp->cond));
698+
THREAD_CHECK_RET(wc_LockMutex(&srtp->mutex));
699+
}
698700
*ekm = srtp->server_srtp_ekm;
699701
*size = srtp->server_srtp_ekm_size;
700702

0 commit comments

Comments
 (0)