Skip to content

Commit

Permalink
Cygwin: console: Fix exit code for non-cygwin process.
Browse files Browse the repository at this point in the history
If non-cygwin process is executed in console, the exit code is not
set correctly. This is because the stub process for non-cygwin app
crashes in fhandler_console::set_disable_master_thread() due to NULL
pointer dereference. This bug was introduced by the commit:
3721a75 ("Cygwin: console: Make the console accessible from
other terminals."), that the pointer cons is accessed before fixing
when it is NULL. This patch fixes the issue.

Fixes: 3721a75 ("Cygwin: console: Make the console accessible from other terminals.")
Reported-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
  • Loading branch information
tyan0 committed Feb 2, 2024
1 parent 23737b0 commit aa73e11
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions winsup/cygwin/fhandler/console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4537,16 +4537,16 @@ fhandler_console::need_console_handler ()
void
fhandler_console::set_disable_master_thread (bool x, fhandler_console *cons)
{
const _minor_t unit = cons->get_minor ();
if (con.disable_master_thread == x)
return;
if (cons == NULL)
{
if (cygheap->ctty && cygheap->ctty->get_major () == DEV_CONS_MAJOR)
cons = (fhandler_console *) cygheap->ctty;
else
return;
}
const _minor_t unit = cons->get_minor ();
if (con.disable_master_thread == x)
return;
cons->acquire_input_mutex (mutex_timeout);
con.disable_master_thread = x;
cons->release_input_mutex ();
Expand Down

0 comments on commit aa73e11

Please sign in to comment.