Skip to content

Commit

Permalink
Fix crash when doing onnetwork pairing with chip-device-ctrl. (#8009)
Browse files Browse the repository at this point in the history
Fixes #7982
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Aug 25, 2021
1 parent 19222b4 commit 1222341
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1588,14 +1588,6 @@ void BasicFailure(void * context, uint8_t status)
#if CHIP_DEVICE_CONFIG_ENABLE_MDNS
void DeviceCommissioner::OnNodeIdResolved(const chip::Mdns::ResolvedNodeData & nodeData)
{
if (mDeviceBeingPaired < kNumMaxActiveDevices)
{
Device * device = &mActiveDevices[mDeviceBeingPaired];
if (device->GetDeviceId() == nodeData.mPeerId.GetNodeId() && mCommissioningStage == CommissioningStage::kFindOperational)
{
AdvanceCommissioningStage(CHIP_NO_ERROR);
}
}
DeviceController::OnNodeIdResolved(nodeData);
OperationalDiscoveryComplete(nodeData.mPeerId.GetNodeId());
}
Expand All @@ -1619,6 +1611,16 @@ void DeviceCommissioner::OnDeviceConnectedFn(void * context, Device * device)
{
DeviceCommissioner * commissioner = reinterpret_cast<DeviceCommissioner *>(context);
VerifyOrReturn(commissioner != nullptr, ChipLogProgress(Controller, "Device connected callback with null context. Ignoring"));

if (commissioner->mDeviceBeingPaired < kNumMaxActiveDevices)
{
Device * deviceBeingPaired = &commissioner->mActiveDevices[commissioner->mDeviceBeingPaired];
if (device == deviceBeingPaired && commissioner->mCommissioningStage == CommissioningStage::kFindOperational)
{
commissioner->AdvanceCommissioningStage(CHIP_NO_ERROR);
}
}

VerifyOrReturn(commissioner->mPairingDelegate != nullptr,
ChipLogProgress(Controller, "Device connected callback with null pairing delegate. Ignoring"));
commissioner->mPairingDelegate->OnCommissioningComplete(device->GetDeviceId(), CHIP_NO_ERROR);
Expand Down

0 comments on commit 1222341

Please sign in to comment.