diff --git a/src/ble/BLEEndPoint.cpp b/src/ble/BLEEndPoint.cpp index 337e72e70151f2..cfbc86d491464b 100644 --- a/src/ble/BLEEndPoint.cpp +++ b/src/ble/BLEEndPoint.cpp @@ -586,8 +586,15 @@ CHIP_ERROR BLEEndPoint::Init(BleLayer * bleLayer, BLE_CONNECTION_OBJECT connObj, return CHIP_NO_ERROR; } +void BLEEndPoint::AddRef() +{ + VerifyOrDie(mRefCount < UINT32_MAX); + mRefCount++; +} + void BLEEndPoint::Release() { + VerifyOrDie(mRefCount > 0u); // Decrement the ref count. When it reaches zero, NULL out the pointer to the chip::System::Layer // object. This effectively declared the object free and ready for re-allocation. mRefCount--; diff --git a/src/ble/BLEEndPoint.h b/src/ble/BLEEndPoint.h index feee860ecbd7a3..7a50256ca064a4 100644 --- a/src/ble/BLEEndPoint.h +++ b/src/ble/BLEEndPoint.h @@ -114,7 +114,7 @@ class DLL_EXPORT BLEEndPoint uint32_t mRefCount; - void AddRef() { mRefCount++; } + void AddRef(); void Release(); // Private data members: