diff options
author | C. McEnroe | 2020-02-04 19:06:54 -0500 |
---|---|---|
committer | C. McEnroe | 2020-02-04 19:06:54 -0500 |
commit | f3fb466a31d78431a686981b7d9b718385591bce (patch) | |
tree | eeaac9ef363fa585c7d574ec70eb9ae36fc7fa06 | |
parent | 5e9863fa82f674ad8eb05148eade5c859a32c7ba (diff) |
Only check revents if nfds > 0
If an error occurs, poll leaves the array unmodified.
-rw-r--r-- | chat.c | 6 |
1 files changed, 3 insertions, 3 deletions
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(); } |