Skip to content

Commit 1530592

Browse files
lzgrablic02pull[bot]
authored andcommitted
BLEEndPoint ref count overflow check (#16046)
* BLEEndPoint ref count overflow check * Assert preconditions for BLEEndPoint ref counting
1 parent 81e053d commit 1530592

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/ble/BLEEndPoint.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,15 @@ CHIP_ERROR BLEEndPoint::Init(BleLayer * bleLayer, BLE_CONNECTION_OBJECT connObj,
586586
return CHIP_NO_ERROR;
587587
}
588588

589+
void BLEEndPoint::AddRef()
590+
{
591+
VerifyOrDie(mRefCount < UINT32_MAX);
592+
mRefCount++;
593+
}
594+
589595
void BLEEndPoint::Release()
590596
{
597+
VerifyOrDie(mRefCount > 0u);
591598
// Decrement the ref count. When it reaches zero, NULL out the pointer to the chip::System::Layer
592599
// object. This effectively declared the object free and ready for re-allocation.
593600
mRefCount--;

src/ble/BLEEndPoint.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class DLL_EXPORT BLEEndPoint
114114

115115
uint32_t mRefCount;
116116

117-
void AddRef() { mRefCount++; }
117+
void AddRef();
118118
void Release();
119119

120120
// Private data members:

0 commit comments

Comments
 (0)