From 0436ae71c091d0ad92efec370435ee2cfe6a7cbf Mon Sep 17 00:00:00 2001 From: Christopher Brannon Date: Mon, 10 Oct 2016 18:24:15 -0700 Subject: [PATCH] Mutex needs to be locked when waiting on the condition variable. --- src/libespeak-ng/event.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libespeak-ng/event.c b/src/libespeak-ng/event.c index 954d4730..c1dcd1f0 100644 --- a/src/libespeak-ng/event.c +++ b/src/libespeak-ng/event.c @@ -237,9 +237,6 @@ espeak_ng_STATUS event_clear_all() } else init(); // clear pending events - if ((status = pthread_mutex_unlock(&my_mutex)) != ENS_OK) - return status; - if (a_event_is_running) { while (my_stop_is_acknowledged == 0) { while ((pthread_cond_wait(&my_cond_stop_is_acknowledged, &my_mutex) == -1) && errno == EINTR) @@ -247,6 +244,9 @@ espeak_ng_STATUS event_clear_all() } } + if ((status = pthread_mutex_unlock(&my_mutex)) != ENS_OK) + return status; + return ENS_OK; }