mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-22 13:10:55 +01:00
Prevent notifications from triggering exception while deleting services.
If we client just connected and a notification comes before deleting services it could cause an exception when accessing a vector that is being deleted. This will check the connection established flag before processing of notifications.
This commit is contained in:
parent
765d5b1be7
commit
4f4883d6ba
1 changed files with 7 additions and 1 deletions
|
@ -260,13 +260,13 @@ bool NimBLEClient::connect(const NimBLEAddress &address, bool deleteAttibutes) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
NIMBLE_LOGI(LOG_TAG, "Connection established");
|
NIMBLE_LOGI(LOG_TAG, "Connection established");
|
||||||
m_connEstablished = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(deleteAttibutes) {
|
if(deleteAttibutes) {
|
||||||
deleteServices();
|
deleteServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_connEstablished = true;
|
||||||
m_pClientCallbacks->onConnect(this);
|
m_pClientCallbacks->onConnect(this);
|
||||||
|
|
||||||
NIMBLE_LOGD(LOG_TAG, "<< connect()");
|
NIMBLE_LOGD(LOG_TAG, "<< connect()");
|
||||||
|
@ -840,6 +840,12 @@ uint16_t NimBLEClient::getMTU() {
|
||||||
if(client->m_conn_id != event->notify_rx.conn_handle)
|
if(client->m_conn_id != event->notify_rx.conn_handle)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
// If a notification comes before this flag is set we might
|
||||||
|
// access a vector while it is being cleared in connect()
|
||||||
|
if(!client->m_connEstablished) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
NIMBLE_LOGD(LOG_TAG, "Notify Recieved for handle: %d",
|
NIMBLE_LOGD(LOG_TAG, "Notify Recieved for handle: %d",
|
||||||
event->notify_rx.attr_handle);
|
event->notify_rx.attr_handle);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue