Skip to content

Commit

Permalink
Conditional freeing of rendezvous session when trying to unpair device (
Browse files Browse the repository at this point in the history
#5958)

* Conditional freeing of rendezvous session when trying to unpair device

* Address review comment

* Add extra check for mDeviceBeingPaired
  • Loading branch information
yufengwangca authored Apr 14, 2021
1 parent 7d33476 commit 1a369d5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,16 @@ CHIP_ERROR DeviceCommissioner::UnpairDevice(NodeId remoteDeviceId)
{
// TODO: Send unpairing message to the remote device.

FreeRendezvousSession();
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);

if (mDeviceBeingPaired < kNumMaxActiveDevices)
{
Device * device = &mActiveDevices[mDeviceBeingPaired];
if (device->GetDeviceId() == remoteDeviceId)
{
FreeRendezvousSession();
}
}

if (mStorageDelegate != nullptr)
{
Expand Down

0 comments on commit 1a369d5

Please sign in to comment.