Skip to content

Commit

Permalink
Fix ExchangeContext leak in chip_im_initiator (Fix: #6915)
Browse files Browse the repository at this point in the history
  • Loading branch information
kghost committed May 18, 2021
1 parent 805a4b3 commit 544887e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/messaging/ExchangeMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
#include <support/RandUtils.h>
#include <support/logging/CHIPLogging.h>

#if CONFIG_DEVICE_LAYER
#include <platform/CHIPDeviceLayer.h>
#include <platform/PlatformManager.h>
#endif

using namespace chip::Encoding;
using namespace chip::Inet;
using namespace chip::System;
Expand Down Expand Up @@ -94,6 +99,10 @@ CHIP_ERROR ExchangeManager::Init(SecureSessionMgr * sessionMgr)

CHIP_ERROR ExchangeManager::Shutdown()
{
// TODO(#6919): This doesn't compile for Android, because Android has no device layer.
#if CONFIG_DEVICE_LAYER
DeviceLayer::PlatformMgr().LockChipStack();
#endif
mReliableMessageMgr.Shutdown();

mContextPool.ForEachActiveObject([](auto * ec) {
Expand All @@ -109,6 +118,9 @@ CHIP_ERROR ExchangeManager::Shutdown()
}

mState = State::kState_NotInitialized;
#if CONFIG_DEVICE_LAYER
DeviceLayer::PlatformMgr().UnlockChipStack();
#endif

return CHIP_NO_ERROR;
}
Expand Down

0 comments on commit 544887e

Please sign in to comment.