Fix potential CORRUPT HEAP problem on libraries/BLE/src/BLEDevice.cpp (#7597)
* Update BLEDevice.cpp fix potential CORRUPT HEAP problem * move mux to BLEDevice class
This commit is contained in:
parent
94fd529e36
commit
bb8c8559b6
2 changed files with 6 additions and 0 deletions
|
|
@ -629,10 +629,15 @@ void BLEDevice::addPeerDevice(void* peer, bool _client, uint16_t conn_id) {
|
|||
m_connectedClientsMap.insert(std::pair<uint16_t, conn_status_t>(conn_id, status));
|
||||
}
|
||||
|
||||
//there may have some situation that invoking this function simultaneously, that will cause CORRUPT HEAP
|
||||
//let this function serializable
|
||||
portMUX_TYPE BLEDevice::mux = portMUX_INITIALIZER_UNLOCKED;
|
||||
void BLEDevice::removePeerDevice(uint16_t conn_id, bool _client) {
|
||||
portENTER_CRITICAL(&mux);
|
||||
log_i("remove: %d, GATT role %s", conn_id, _client?"client":"server");
|
||||
if(m_connectedClientsMap.find(conn_id) != m_connectedClientsMap.end())
|
||||
m_connectedClientsMap.erase(conn_id);
|
||||
portEXIT_CRITICAL(&mux);
|
||||
}
|
||||
|
||||
/* multi connect support */
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ private:
|
|||
static BLEAdvertising* m_bleAdvertising;
|
||||
static esp_gatt_if_t getGattcIF();
|
||||
static std::map<uint16_t, conn_status_t> m_connectedClientsMap;
|
||||
static portMUX_TYPE mux;
|
||||
|
||||
static void gattClientEventHandler(
|
||||
esp_gattc_cb_event_t event,
|
||||
|
|
|
|||
Loading…
Reference in a new issue