Skip to content

Commit e948484

Browse files
committed
ttyplot.c: Fix crash with -O1 on Ctrl+C
To reproduce: 1. Run "ttyplot" (as is) 2. Hit Ctrl+C 3. See message "*** bit out of range 0 - FD_SETSIZE on fd_set ***: terminate" and "Aborted"
1 parent 68f5554 commit e948484

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

ttyplot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ static int wait_for_events(int signal_read_fd, int tty, bool stdin_is_open, stru
481481
ret |= EVENT_SIGNAL_READABLE;
482482
}
483483

484-
if (FD_ISSET(tty, &read_fds)) {
484+
if ((tty != -1) && FD_ISSET(tty, &read_fds)) {
485485
ret |= EVENT_TTY_READABLE;
486486
}
487487

0 commit comments

Comments
 (0)