Fix ExchangeContext leaks (#21846)
diff --git a/src/messaging/ExchangeMgr.cpp b/src/messaging/ExchangeMgr.cpp
index 410183e..9859854 100644
--- a/src/messaging/ExchangeMgr.cpp
+++ b/src/messaging/ExchangeMgr.cpp
@@ -107,7 +107,7 @@
mState = State::kState_NotInitialized;
}
-ExchangeContext * ExchangeManager::NewContext(const SessionHandle & session, ExchangeDelegate * delegate)
+ExchangeContext * ExchangeManager::NewContext(const SessionHandle & session, ExchangeDelegate * delegate, bool isInitiator)
{
if (!session->IsActiveSession())
{
@@ -115,7 +115,7 @@
ChipLogError(ExchangeManager, "NewContext failed: session inactive");
return nullptr;
}
- return mContextPool.CreateObject(this, mNextExchangeId++, session, true, delegate);
+ return mContextPool.CreateObject(this, mNextExchangeId++, session, isInitiator, delegate);
}
CHIP_ERROR ExchangeManager::RegisterUnsolicitedMessageHandlerForProtocol(Protocols::Id protocolId,