From 9c8ce8e97ee453ada1f8a2ee0b4afce38d66e100 Mon Sep 17 00:00:00 2001 From: C Freeman Date: Tue, 11 Jan 2022 23:29:16 -0500 Subject: [PATCH] Add a check for device != null on commissioning. (#13473) --- src/controller/CHIPDeviceController.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 073d15f2256d5b..f660a40bd73ee9 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -856,7 +856,8 @@ CHIP_ERROR DeviceCommissioner::Commission(NodeId remoteDeviceId, CommissioningPa // TODO(cecille): Can we get rid of mDeviceBeingCommissioned and use the remote id instead? Would require storing the // commissioning stage in the device. CommissioneeDeviceProxy * device = mDeviceBeingCommissioned; - if (device->GetDeviceId() != remoteDeviceId || (!device->IsSecureConnected() && !device->IsSessionSetupInProgress())) + if (device == nullptr || device->GetDeviceId() != remoteDeviceId || + (!device->IsSecureConnected() && !device->IsSessionSetupInProgress())) { ChipLogError(Controller, "Invalid device for commissioning" ChipLogFormatX64, ChipLogValueX64(remoteDeviceId)); return CHIP_ERROR_INCORRECT_STATE;