summaryrefslogtreecommitdiff
path: root/Libraries/LibCore
diff options
context:
space:
mode:
authorjoshua stein <jcs@jcs.org>2020-02-02 01:10:37 -0600
committerAndreas Kling <kling@serenityos.org>2020-02-05 18:39:45 +0100
commitdac07a5d762cf77dead2a141cf070bc5c9d31242 (patch)
tree98b79413b9dbbcf0d10a02a266dd1c28f970954e /Libraries/LibCore
parent0c4c5b5eb74aa40cecd7fa58c7de3ca0076c1565 (diff)
downloadserenity-dac07a5d762cf77dead2a141cf070bc5c9d31242.zip
LibCore: CEventLoop: If timeval_sub makes tv_sec negative, use 0
Diffstat (limited to 'Libraries/LibCore')
-rw-r--r--Libraries/LibCore/CEventLoop.cpp4
1 files changed, 4 insertions, 0 deletions
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;
}