Cygwin: pty: Fix segfault caused when tcflush() is called.

- After commit 253352e796, mc (midnight
  commander) crashes with segfault if the shell is bash. This is due
  to NULL pointer access in read(). This patch fixes the issue.
  Addresses::
    https://cygwin.com/pipermail/cygwin/2021-February/247870.html
This commit is contained in:
Takashi Yano via Cygwin-patches 2021-02-21 07:45:16 +09:00 committed by Corinna Vinschen
parent 246121534a
commit 18b91fbe58
1 changed files with 5 additions and 2 deletions

View File

@ -1474,8 +1474,11 @@ wait_retry:
out: out:
termios_printf ("%d = read(%p, %lu)", totalread, ptr, len); termios_printf ("%d = read(%p, %lu)", totalread, ptr, len);
len = (size_t) totalread; len = (size_t) totalread;
bool saw_eol = totalread > 0 && strchr ("\r\n", ptr0[totalread -1]); if (ptr0)
mask_switch_to_pcon_in (false, saw_eol); { /* Not tcflush() */
bool saw_eol = totalread > 0 && strchr ("\r\n", ptr0[totalread -1]);
mask_switch_to_pcon_in (false, saw_eol);
}
} }
int int