From 74b5c59887a381ca02c8193384bd89968c8409a6 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Mon, 10 Feb 2025 09:27:56 -0600 Subject: [PATCH] fix(NimBLEDevice): fix crash when pairing table is full * Add missing definition for default device callbacks (which prevents calling the `setDeviceCallbacks` method) * Ensure `m_pDeviceCallbacks` inital value is set to `&defaultDeviceCallbacks` to prevent crash when pairing table is full After #295 any time the pairing table fills up, the device will crash on the next pairing attempt. --- src/NimBLEDevice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NimBLEDevice.cpp b/src/NimBLEDevice.cpp index 52357f8..05019cf 100644 --- a/src/NimBLEDevice.cpp +++ b/src/NimBLEDevice.cpp @@ -76,7 +76,8 @@ extern "C" void ble_store_config_init(void); /** * Singletons for the NimBLEDevice. */ -NimBLEDeviceCallbacks* NimBLEDevice::m_pDeviceCallbacks = nullptr; +NimBLEDeviceCallbacks NimBLEDevice::defaultDeviceCallbacks{}; +NimBLEDeviceCallbacks* NimBLEDevice::m_pDeviceCallbacks = &defaultDeviceCallbacks; # if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER) NimBLEScan* NimBLEDevice::m_pScan = nullptr;