diff --git a/src/system/SystemPacketBuffer.cpp b/src/system/SystemPacketBuffer.cpp index 3f6c136bcb152b..f47a54278433e2 100644 --- a/src/system/SystemPacketBuffer.cpp +++ b/src/system/SystemPacketBuffer.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -431,6 +432,8 @@ void PacketBuffer::AddRef() pbuf_ref(this); #else // !CHIP_SYSTEM_CONFIG_USE_LWIP LOCK_BUF_POOL(); + VerifyOrDieWithMsg(this->ref < std::numeric_limitsref)>::max(), chipSystemLayer, + "packet buffer refcount overflow"); ++this->ref; UNLOCK_BUF_POOL(); #endif // !CHIP_SYSTEM_CONFIG_USE_LWIP