Skip to content

Commit

Permalink
ttyplot.c: Fix crash with -O1 on Ctrl+C
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
hartwork committed Dec 25, 2023
1 parent 68f5554 commit e948484
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ttyplot.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ static int wait_for_events(int signal_read_fd, int tty, bool stdin_is_open, stru
ret |= EVENT_SIGNAL_READABLE;
}

if (FD_ISSET(tty, &read_fds)) {
if ((tty != -1) && FD_ISSET(tty, &read_fds)) {
ret |= EVENT_TTY_READABLE;
}

Expand Down

0 comments on commit e948484

Please sign in to comment.