Skip to content

Commit bc333cc

Browse files
JPZVh2zero
authored andcommitted
Fixed unhandled exception on handleGapEvent
Somehow, the conn_handle can have the value of `0xffff`. Not sure why or how, but anyway it should be managed before moving forward on NimBLECharacteristic::handleGapEvent. Otherwise, an unhandled exception will occur on `assert(rc == 0);`
1 parent 53cb3ce commit bc333cc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/NimBLECharacteristic.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ int NimBLECharacteristic::handleGapEvent(uint16_t conn_handle, uint16_t attr_han
261261
struct ble_gatt_access_ctxt *ctxt,
262262
void *arg)
263263
{
264+
if (conn_handle > BLE_HCI_LE_CONN_HANDLE_MAX)
265+
{
266+
NIMBLE_LOGW(LOG_TAG, "Conn_handle (%d) is above the maximum value (%d)", conn_handle, BLE_HCI_LE_CONN_HANDLE_MAX);
267+
return BLE_ATT_ERR_INVALID_HANDLE;
268+
}
269+
264270
const ble_uuid_t *uuid;
265271
int rc;
266272
struct ble_gap_conn_desc desc;

0 commit comments

Comments
 (0)