Skip to content

Commit f33c62b

Browse files
authored
Fix crash for eps32 commissioner if ble disconnect during commissioning (#33332)
1 parent 947dc7c commit f33c62b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/platform/ESP32/nimble/BLEManagerImpl.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,10 @@ bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const
503503
uint8_t value[2];
504504
int rc;
505505
struct peer * peer = peer_find(conId);
506+
if (peer == nullptr)
507+
{
508+
return false;
509+
}
506510

507511
dsc = peer_dsc_find_uuid(peer, (ble_uuid_t *) (&ShortUUID_CHIPoBLEService), (ble_uuid_t *) (&UUID_CHIPoBLEChar_TX),
508512
(ble_uuid_t *) (&ShortUUID_CHIPoBLE_CharTx_Desc));
@@ -537,6 +541,10 @@ bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, cons
537541
uint8_t value[2];
538542
int rc;
539543
struct peer * peer = peer_find(conId);
544+
if (peer == nullptr)
545+
{
546+
return false;
547+
}
540548

541549
dsc = peer_dsc_find_uuid(peer, (ble_uuid_t *) (&ShortUUID_CHIPoBLEService), (ble_uuid_t *) (&UUID_CHIPoBLEChar_TX),
542550
(ble_uuid_t *) (&ShortUUID_CHIPoBLE_CharTx_Desc));

0 commit comments

Comments
 (0)