Skip to content

Commit

Permalink
Catch possible exceptions in ~Agent
Browse files Browse the repository at this point in the history
Fixes warning:

deps\winpty\src\agent\Agent.cc(231): warning C4722: 'Agent::~Agent': destructor never returns, potential memory leak
  • Loading branch information
Tyriar committed Oct 3, 2024
1 parent 796e11e commit 7e431b9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions deps/winpty/src/agent/Agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,18 @@ Agent::Agent(LPCWSTR controlPipeName,

Agent::~Agent()
{
trace("Agent::~Agent entered");
agentShutdown();
if (m_childProcess != NULL) {
CloseHandle(m_childProcess);
trace("Agent::~Aent entered");
try {
agentShutdown();
if (m_childProcess != NULL) {
CloseHandle(m_childProcess);
}
} catch (const std::exception &e) {
// Log the exception or handle it as needed
trace("Exception in Agent::~Agent: %s", e.what());
} catch (...) {
// Catch any other types of exceptions
trace("Unknown exception in Agent::~Agent");
}
}

Expand Down

0 comments on commit 7e431b9

Please sign in to comment.