From 74def922a7efcd399b926fa75ed2730db623156f Mon Sep 17 00:00:00 2001 From: torlando-tech Date: Thu, 5 Mar 2026 12:05:50 -0500 Subject: [PATCH] Guard enableNotifications against missing connection entry Co-Authored-By: Claude Opus 4.6 --- lib/ble_interface/platforms/NimBLEPlatform.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ble_interface/platforms/NimBLEPlatform.cpp b/lib/ble_interface/platforms/NimBLEPlatform.cpp index 44acc293..e21c73b7 100644 --- a/lib/ble_interface/platforms/NimBLEPlatform.cpp +++ b/lib/ble_interface/platforms/NimBLEPlatform.cpp @@ -1906,9 +1906,11 @@ bool NimBLEPlatform::enableNotifications(uint16_t conn_handle, bool enable) { } auto conn_it = _connections.find(conn_handle); - if (conn_it != _connections.end()) { - expected_peer = conn_it->second.peer_address; + if (conn_it == _connections.end()) { + xSemaphoreGive(_conn_mutex); + return false; } + expected_peer = conn_it->second.peer_address; beginWriteOperation(); xSemaphoreGive(_conn_mutex);