From 13f677a6f36982c3c4a53c656514fada6b3df7be Mon Sep 17 00:00:00 2001 From: Brad House Date: Sun, 14 Apr 2024 20:56:35 -0400 Subject: [PATCH] ares_queue_wait_empty() does not honor timeout_ms >= 0 There is a missing break statement in the case that timeout_ms >= 0 leading to a possible infinite loop. Fixes Issue: #742 Fix By: Brad House (@bradh352) --- src/lib/ares__threads.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/ares__threads.c b/src/lib/ares__threads.c index f6de8c69..44442357 100644 --- a/src/lib/ares__threads.c +++ b/src/lib/ares__threads.c @@ -585,6 +585,10 @@ ares_status_t ares_queue_wait_empty(ares_channel_t *channel, int timeout_ms) status = ares__thread_cond_timedwait(channel->cond_empty, channel->lock, tms); } + + /* Either there was a timeout or we were signaled that the queue was + * empty. Don't loop */ + break; } } ares__thread_mutex_unlock(channel->lock);