Skip to content

Commit 2a45d8b

Browse files
committed
Fix crash when peer disconnects from the server.
If the server has not created a client instance then the device would crash when the peer disconnects due to nullptr access.
1 parent 5ade97a commit 2a45d8b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/NimBLEServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) {
397397
}
398398
}
399399

400-
if (pServer->m_pClient->m_connHandle == event->disconnect.conn.conn_handle) {
400+
if (pServer->m_pClient && pServer->m_pClient->m_connHandle == event->disconnect.conn.conn_handle) {
401401
// If this was also the client make sure it's flagged as disconnected.
402402
pServer->m_pClient->m_connHandle = BLE_HS_CONN_HANDLE_NONE;
403403
}

0 commit comments

Comments
 (0)