aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2024-02-02 13:59:19 +0900
committerTakashi Yano <takashi.yano@nifty.ne.jp>2024-02-02 14:26:23 +0900
commitaa73e115242612bf8b5f8670c0c7d398693d1d84 (patch)
treeca752c08959b918e2e4c67dd9ad07595cd5e6e10 /winsup
parent23737b04cc52a0473d524661a51779224c0d7b8b (diff)
downloadnewlib-aa73e115242612bf8b5f8670c0c7d398693d1d84.zip
newlib-aa73e115242612bf8b5f8670c0c7d398693d1d84.tar.gz
newlib-aa73e115242612bf8b5f8670c0c7d398693d1d84.tar.bz2
Cygwin: console: Fix exit code for non-cygwin process.
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: 3721a756b0d8 ("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: 3721a756b0d8 ("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>
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/fhandler/console.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc
index b924a6b..6a42b49 100644
--- a/winsup/cygwin/fhandler/console.cc
+++ b/winsup/cygwin/fhandler/console.cc
@@ -4537,9 +4537,6 @@ 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)
@@ -4547,6 +4544,9 @@ fhandler_console::set_disable_master_thread (bool x, fhandler_console *cons)
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 ();