Skip to content

Commit

Permalink
Make sure we don't crash when commissioning with no pairing delegate. (
Browse files Browse the repository at this point in the history
…#21505) (#21514)

Fixes #21492

Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
woody-apple and bzbarsky-apple authored Aug 2, 2022
1 parent 524b2bd commit 362d570
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,10 @@ void DeviceCommissioner::OnSessionEstablished(const SessionHandle & session)

ChipLogDetail(Controller, "Remote device completed SPAKE2+ handshake");

mPairingDelegate->OnPairingComplete(CHIP_NO_ERROR);
if (mPairingDelegate != nullptr)
{
mPairingDelegate->OnPairingComplete(CHIP_NO_ERROR);
}

if (mRunCommissioningAfterConnection)
{
Expand Down
10 changes: 8 additions & 2 deletions src/controller/SetUpCodePairer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,10 @@ void SetUpCodePairer::OnPairingComplete(CHIP_ERROR error)
mSystemLayer->CancelTimer(OnDeviceDiscoveredTimeoutCallback, this);

ResetDiscoveryState();
pairingDelegate->OnPairingComplete(error);
if (pairingDelegate != nullptr)
{
pairingDelegate->OnPairingComplete(error);
}
return;
}

Expand All @@ -449,7 +452,10 @@ void SetUpCodePairer::OnPairingComplete(CHIP_ERROR error)
return;
}

pairingDelegate->OnPairingComplete(error);
if (pairingDelegate != nullptr)
{
pairingDelegate->OnPairingComplete(error);
}
}

void SetUpCodePairer::OnPairingDeleted(CHIP_ERROR error)
Expand Down

0 comments on commit 362d570

Please sign in to comment.