diff --git a/src/platform/ESP32/nimble/BLEManagerImpl.cpp b/src/platform/ESP32/nimble/BLEManagerImpl.cpp index 9b09fa17292036..909af7bd8f8d6b 100644 --- a/src/platform/ESP32/nimble/BLEManagerImpl.cpp +++ b/src/platform/ESP32/nimble/BLEManagerImpl.cpp @@ -659,7 +659,11 @@ bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const ChipBle return false; } - assert(pBuf->DataLength() <= UINT16_MAX); + if (pBuf->DataLength() > UINT16_MAX) + { + ChipLogError(Ble, "Buffer data Length is too long"); + return false; + } rc = ble_gattc_write_flat(conId, chr->chr.val_handle, pBuf->Start(), static_cast(pBuf->DataLength()), OnWriteComplete, this); if (rc != 0)