Skip to content

Commit

Permalink
Don't let ConptyConnection be UAF (microsoft#4871)
Browse files Browse the repository at this point in the history
I noticed a crash in debug builds when a connected application terminates;
we get its exit code, then we destruct, and the u16state is used after it's
destructed by us parsing the process's last words.

We should have been doing this all along.
  • Loading branch information
DHowett authored and abhijeetviswam committed Mar 12, 2020
1 parent 22327fc commit a7e519a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cascadia/TerminalConnection/ConptyConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation

DWORD ConptyConnection::_OutputThread()
{
// Keep us alive until the output thread terminates; the destructor
// won't wait for us, and the known exit points _do_.
auto strongThis{ get_strong() };

// process the data of the output pipe in a loop
while (true)
{
Expand Down

0 comments on commit a7e519a

Please sign in to comment.