Kernel panic when delete BLEClient object with descriptor characteristic (#8010)

* Update BLERemoteCharacteristic.cpp

Fix kernel panic issue when trying to release BLEClient when the target device have a ble descriptor.

* Update BLERemoteCharacteristic.cpp

Co-authored-by: Lucas Saavedra Vaz <lucassvaz@yahoo.com.br>

---------

Co-authored-by: Lucas Saavedra Vaz <lucas.vaz@espressif.com>
Co-authored-by: Lucas Saavedra Vaz <lucassvaz@yahoo.com.br>
This commit is contained in:
Chester 2023-11-30 20:26:23 +08:00 committed by GitHub
parent 8985a77e3e
commit 5fcdb8412d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -520,10 +520,9 @@ void BLERemoteCharacteristic::registerForNotify(notify_callback notifyCallback,
void BLERemoteCharacteristic::removeDescriptors() {
// Iterate through all the descriptors releasing their storage and erasing them from the map.
for (auto &myPair : m_descriptorMap) {
m_descriptorMap.erase(myPair.first);
delete myPair.second;
}
m_descriptorMap.clear(); // Technically not neeeded, but just to be sure.
m_descriptorMap.clear();
} // removeCharacteristics