From dac07a5d762cf77dead2a141cf070bc5c9d31242 Mon Sep 17 00:00:00 2001 From: joshua stein Date: Sun, 2 Feb 2020 01:10:37 -0600 Subject: [PATCH] LibCore: CEventLoop: If timeval_sub makes tv_sec negative, use 0 --- Libraries/LibCore/CEventLoop.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/LibCore/CEventLoop.cpp b/Libraries/LibCore/CEventLoop.cpp index 60f87cfc3e..84d13eecd6 100644 --- a/Libraries/LibCore/CEventLoop.cpp +++ b/Libraries/LibCore/CEventLoop.cpp @@ -371,6 +371,10 @@ void EventLoop::wait_for_event(WaitMode mode) gettimeofday(&now, nullptr); get_next_timer_expiration(timeout); timeval_sub(timeout, now, timeout); + if (timeout.tv_sec < 0) { + timeout.tv_sec = 0; + timeout.tv_usec = 0; + } } else { should_wait_forever = true; }