Skip to content

Commit

Permalink
Fixed unhandled exception on handleGapEvent
Browse files Browse the repository at this point in the history
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);`
  • Loading branch information
JPZV authored and h2zero committed May 29, 2023
1 parent 53cb3ce commit bc333cc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/NimBLECharacteristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ int NimBLECharacteristic::handleGapEvent(uint16_t conn_handle, uint16_t attr_han
struct ble_gatt_access_ctxt *ctxt,
void *arg)
{
if (conn_handle > BLE_HCI_LE_CONN_HANDLE_MAX)
{
NIMBLE_LOGW(LOG_TAG, "Conn_handle (%d) is above the maximum value (%d)", conn_handle, BLE_HCI_LE_CONN_HANDLE_MAX);
return BLE_ATT_ERR_INVALID_HANDLE;
}

const ble_uuid_t *uuid;
int rc;
struct ble_gap_conn_desc desc;
Expand Down

0 comments on commit bc333cc

Please sign in to comment.