diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c index ffda206b8d5ecad70056fa4632a3cc0fce312b16..5e99b3cc635d7fbfb9c4597ef874575d4fdf334a 100644 --- a/src/util/vireventpoll.c +++ b/src/util/vireventpoll.c @@ -357,9 +357,10 @@ static int virEventPollCalculateTimeout(int *timeout) return -1; EVENT_DEBUG("Schedule timeout then=%llu now=%llu", then, now); - *timeout = then - now; - if (*timeout < 0) + if (then <= now) *timeout = 0; + else + *timeout = ((then - now) > INT_MAX) ? INT_MAX : (then - now); } else { *timeout = -1; }