diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c index 528b24c856c77eda46c079a65b5b0ef8ef94bbb7..13f40dcb1a0c7d4892323f024700504f3e90b571 100644 --- a/src/util/vireventpoll.c +++ b/src/util/vireventpoll.c @@ -483,9 +483,9 @@ static int virEventPollDispatchHandles(int nfds, struct pollfd *fds) * fds might be added on end of list, and they're not * in the fds array we've got */ for (i = 0, n = 0; n < nfds && i < eventLoop.handlesCount; n++) { - while ((eventLoop.handles[i].fd != fds[n].fd || - eventLoop.handles[i].events == 0) && - i < eventLoop.handlesCount) { + while (i < eventLoop.handlesCount && + (eventLoop.handles[i].fd != fds[n].fd || + eventLoop.handles[i].events == 0)) { i++; } if (i == eventLoop.handlesCount)