Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2022-01-13 12:18:00 +0300
committerTakashi Yano <takashi.yano@nifty.ne.jp>2022-01-14 17:10:55 +0300
commit4f490c4cef8fd527642dbb5ea5373b373193a49b (patch)
treeb4d7c7a6b2eea901ba689822c39afe2f1cd77cab /winsup
parentaa49985245e4e5b278778b0a47f6ce83cceb4ad4 (diff)
Cygwin: pty: Fix memory leak in master_fwd_thread.
- If master_fwd_thread is terminated by cygthread::terminate_thread(), the opportunity to release tmp_pathbuf is missed, resulting in a memory leak. This patch fixes the issue.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/fhandler_tty.cc6
-rw-r--r--winsup/cygwin/tty.cc1
-rw-r--r--winsup/cygwin/tty.h1
3 files changed, 7 insertions, 1 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 16dbc5c0a..f68e80df9 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2106,7 +2106,9 @@ fhandler_pty_master::close ()
master_ctl = NULL;
}
release_output_mutex ();
- master_fwd_thread->terminate_thread ();
+ get_ttyp ()->stop_fwd_thread = true;
+ WriteFile (to_master_nat, "", 0, NULL, NULL);
+ master_fwd_thread->detach ();
}
}
if (InterlockedDecrement (&master_cnt) == 0)
@@ -2695,6 +2697,8 @@ fhandler_pty_master::pty_master_fwd_thread (const master_fwd_thread_param_t *p)
termios_printf ("ReadFile for forwarding failed, %E");
break;
}
+ if (p->ttyp->stop_fwd_thread)
+ break;
ssize_t wlen = rlen;
char *ptr = outbuf;
if (p->ttyp->pcon_activated)
diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc
index e29d73dcb..789528856 100644
--- a/winsup/cygwin/tty.cc
+++ b/winsup/cygwin/tty.cc
@@ -254,6 +254,7 @@ tty::init ()
last_sig = 0;
mask_flusho = false;
discard_input = false;
+ stop_fwd_thread = false;
}
HANDLE
diff --git a/winsup/cygwin/tty.h b/winsup/cygwin/tty.h
index 25d351a4a..519d7c0d5 100644
--- a/winsup/cygwin/tty.h
+++ b/winsup/cygwin/tty.h
@@ -132,6 +132,7 @@ private:
xfer_dir pcon_input_state;
bool mask_flusho;
bool discard_input;
+ bool stop_fwd_thread;
public:
HANDLE from_master_nat () const { return _from_master_nat; }