mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-28 12:05:47 +08:00
Cygwin: pty: Avoid potential segfault in PTY code when ppid = 1.
This commit is contained in:
parent
1a44ad03e0
commit
831b1569dc
@ -137,9 +137,16 @@ force_attach_to_pcon (HANDLE h)
|
|||||||
/* If the process is running on a console,
|
/* If the process is running on a console,
|
||||||
the parent process should be attached
|
the parent process should be attached
|
||||||
to the same console. */
|
to the same console. */
|
||||||
pinfo p (myself->ppid);
|
DWORD attach_wpid;
|
||||||
|
if (myself->ppid == 1)
|
||||||
|
attach_wpid = ATTACH_PARENT_PROCESS;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pinfo p (myself->ppid);
|
||||||
|
attach_wpid = p->dwProcessId;
|
||||||
|
}
|
||||||
FreeConsole ();
|
FreeConsole ();
|
||||||
if (AttachConsole (p->dwProcessId))
|
if (AttachConsole (attach_wpid))
|
||||||
{
|
{
|
||||||
pcon_attached_to = -1;
|
pcon_attached_to = -1;
|
||||||
attach_done = true;
|
attach_done = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user