Skip to content

Commit

Permalink
Check if m_pServerCallbacks is not null before calling method. (espre…
Browse files Browse the repository at this point in the history
…ssif#5603)

Fixes: espressif#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.
  • Loading branch information
Marcus10110 authored Aug 31, 2021
1 parent 24b76cb commit 9eea85f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libraries/BLE/src/BLEServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ void BLEServer::handleGATTServerEvent(esp_gatts_cb_event_t event, esp_gatt_if_t

case ESP_GATTS_MTU_EVT:
updatePeerMTU(param->mtu.conn_id, param->mtu.mtu);
m_pServerCallbacks->onMtuChanged(this, param);
if (m_pServerCallbacks != nullptr) {
m_pServerCallbacks->onMtuChanged(this, param);
}
break;

// ESP_GATTS_CONNECT_EVT
Expand Down

0 comments on commit 9eea85f

Please sign in to comment.