]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: pty: Add missing pinfo check in transfer_input().
authorTakashi Yano <takashi.yano@nifty.ne.jp>
Mon, 14 Aug 2023 10:48:12 +0000 (19:48 +0900)
committerTakashi Yano <takashi.yano@nifty.ne.jp>
Tue, 15 Aug 2023 23:34:25 +0000 (08:34 +0900)
The commit 10d083c745dd has a bug that lacks a check for pinfo pointer
value for master_pid. This causes segmentation fault if the process
whose pid is master_pid no longer exists. This patch fixes the issue.

Fixes: 10d083c745dd ("Cygwin: pty: Inherit typeahead data between two input pipes.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
winsup/cygwin/fhandler/pty.cc

index e9d9b351d28c1c95333ab09973a79d7a57a28101..df37d9189d7d697b996e3aa2eaf2b702ae251fd4 100644 (file)
@@ -3886,7 +3886,9 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir, HANDLE from, tty *ttyp,
     to = ttyp->to_slave ();
 
   pinfo p (ttyp->master_pid);
-  HANDLE pty_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE, p->dwProcessId);
+  HANDLE pty_owner = NULL;
+  if (p)
+    pty_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE, p->dwProcessId);
   if (pty_owner)
     {
       DuplicateHandle (pty_owner, to, GetCurrentProcess (), &to,
This page took 0.033137 seconds and 5 git commands to generate.