diff options
author | Takashi Yano via Cygwin-patches <cygwin-patches@cygwin.com> | 2021-02-21 07:45:16 +0900 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2021-02-22 10:50:05 +0100 |
commit | 18b91fbe580e747edf0f7ef8edbec4df07bc7245 (patch) | |
tree | 4a7575edad902c02bbc6d6949fa5988b2c9c33a3 | |
parent | 246121534a291d70b1a53f1be85e392981f25e9f (diff) | |
download | cygnal-18b91fbe580e747edf0f7ef8edbec4df07bc7245.tar.gz cygnal-18b91fbe580e747edf0f7ef8edbec4df07bc7245.tar.bz2 cygnal-18b91fbe580e747edf0f7ef8edbec4df07bc7245.zip |
Cygwin: pty: Fix segfault caused when tcflush() is called.
- After commit 253352e796ff9ec9a447e5375f5bc3e2b92b5293, 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
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index d30041af1..3fcaa8277 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -1474,8 +1474,11 @@ wait_retry: out: termios_printf ("%d = read(%p, %lu)", totalread, ptr, len); len = (size_t) totalread; - bool saw_eol = totalread > 0 && strchr ("\r\n", ptr0[totalread -1]); - mask_switch_to_pcon_in (false, saw_eol); + if (ptr0) + { /* Not tcflush() */ + bool saw_eol = totalread > 0 && strchr ("\r\n", ptr0[totalread -1]); + mask_switch_to_pcon_in (false, saw_eol); + } } int |