From 1f747dd0160038eba8f729a3a2a80569eb759665 Mon Sep 17 00:00:00 2001 From: LDA Date: Mon, 19 Aug 2024 00:24:00 +0200 Subject: [PATCH] [FIX] Fix potential race condition --- src/XMPPThread/ReListener.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/XMPPThread/ReListener.c b/src/XMPPThread/ReListener.c index 62ff10b..04cae69 100644 --- a/src/XMPPThread/ReListener.c +++ b/src/XMPPThread/ReListener.c @@ -331,6 +331,7 @@ ParseeAwaitStanza(char *identifier, int64_t timeout) { /* Timeout detected, give up regardless of the status of our * search. */ + pthread_mutex_lock(&await_lock); HashMapDelete(await_table, identifier); pthread_mutex_unlock(&await_lock); break; @@ -344,7 +345,9 @@ ParseeAwaitStanza(char *identifier, int64_t timeout) stanza = awa.stanza; pthread_mutex_unlock(&awa.cond_lock); + pthread_mutex_lock(&await_lock); pthread_cond_destroy(&awa.condition); pthread_mutex_destroy(&awa.cond_lock); + pthread_mutex_unlock(&await_lock); return stanza; }