Check if m_pServerCallbacks is not null before calling method. (#5603)

Fixes: https://github.com/espressif/arduino-esp32/issues/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.
This commit is contained in:
Mark 2021-08-30 23:20:02 -07:00 committed by GitHub
parent 24b76cbb14
commit 9eea85f9ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -157,7 +157,9 @@ void BLEServer::handleGATTServerEvent(esp_gatts_cb_event_t event, esp_gatt_if_t
case ESP_GATTS_MTU_EVT: case ESP_GATTS_MTU_EVT:
updatePeerMTU(param->mtu.conn_id, param->mtu.mtu); updatePeerMTU(param->mtu.conn_id, param->mtu.mtu);
if (m_pServerCallbacks != nullptr) {
m_pServerCallbacks->onMtuChanged(this, param); m_pServerCallbacks->onMtuChanged(this, param);
}
break; break;
// ESP_GATTS_CONNECT_EVT // ESP_GATTS_CONNECT_EVT