Skip to content

Commit

Permalink
BLEEndPoint ref count overflow check
Browse files Browse the repository at this point in the history
  • Loading branch information
lzgrablic02 committed Mar 10, 2022
1 parent cd44f9b commit e8cd248
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/ble/BLEEndPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,16 @@ CHIP_ERROR BLEEndPoint::Init(BleLayer * bleLayer, BLE_CONNECTION_OBJECT connObj,
return CHIP_NO_ERROR;
}

void BLEEndPoint::AddRef()
{
if (mRefCount == UINT32_MAX)
{
return;
}

mRefCount++;
}

void BLEEndPoint::Release()
{
// Decrement the ref count. When it reaches zero, NULL out the pointer to the chip::System::Layer
Expand Down
2 changes: 1 addition & 1 deletion src/ble/BLEEndPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class DLL_EXPORT BLEEndPoint

uint32_t mRefCount;

void AddRef() { mRefCount++; }
void AddRef();
void Release();

// Private data members:
Expand Down

0 comments on commit e8cd248

Please sign in to comment.