OSDN Git Service

check for errors in all pollfd structs from qt_safe_poll()
authorIvailo Monev <xakepa10@gmail.com>
Fri, 24 Sep 2021 13:41:23 +0000 (16:41 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Fri, 24 Sep 2021 13:41:23 +0000 (16:41 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/kernel/qcore_unix_p.h

index ee67948..453fcd9 100644 (file)
@@ -262,9 +262,11 @@ static inline int qt_safe_poll(struct pollfd *fds, nfds_t nfds, int timeout)
 {
     int ret;
     Q_EINTR_LOOP(ret, ::poll(fds, nfds, timeout));
-    if ((fds->revents & POLLERR) != 0 || (fds->revents & POLLHUP) != 0 || (fds->revents & POLLNVAL) != 0) {
-        // select() compat
-        return -1;
+    for (nfds_t i = 0; i < nfds; i++) {
+        if ((fds[i].revents & POLLERR) != 0 || (fds[i].revents & POLLHUP) != 0 || (fds[i].revents & POLLNVAL) != 0) {
+            // select() compat
+            return -1;
+        }
     }
     return ret;
 }