Skip to content

Commit 9eea85f

Browse files
authored
Check if m_pServerCallbacks is not null before calling method. (#5603)
Fixes: #5573 To reproduce: 1. Run any sample code that starts a BLE server, and does not call `setCallbacks`. 2. Connect to the device using the "LightBlue" app on iOS. 3. Observe crash shown in the issue linked above.
1 parent 24b76cb commit 9eea85f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: libraries/BLE/src/BLEServer.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ void BLEServer::handleGATTServerEvent(esp_gatts_cb_event_t event, esp_gatt_if_t
157157

158158
case ESP_GATTS_MTU_EVT:
159159
updatePeerMTU(param->mtu.conn_id, param->mtu.mtu);
160-
m_pServerCallbacks->onMtuChanged(this, param);
160+
if (m_pServerCallbacks != nullptr) {
161+
m_pServerCallbacks->onMtuChanged(this, param);
162+
}
161163
break;
162164

163165
// ESP_GATTS_CONNECT_EVT

0 commit comments

Comments
 (0)