From f3fb466a31d78431a686981b7d9b718385591bce Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Tue, 4 Feb 2020 19:06:54 -0500 Subject: Only check revents if nfds > 0 If an error occurs, poll leaves the array unmodified. --- chat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'chat.c') diff --git a/chat.c b/chat.c index 3aa4ad2..1656a53 100644 --- a/chat.c +++ b/chat.c @@ -125,11 +125,11 @@ int main(int argc, char *argv[]) { if (signals[SIGWINCH]) { signals[SIGWINCH] = 0; cursesWinch(SIGWINCH); - fds[0].revents = POLLIN; + uiRead(); } - if (fds[0].revents) uiRead(); - if (fds[1].revents) ircRecv(); + if (nfds > 0 && fds[0].revents) uiRead(); + if (nfds > 0 && fds[1].revents) ircRecv(); uiDraw(); } -- cgit 1.4.1-2-gfad0