Better handling of overflowing integer values. r+sr=roc@ocallahan.org, a=beltzner@mozilla.com

This commit is contained in:
Johnny Stenback 2008-07-01 15:46:12 -07:00
parent cd55c6b951
commit f9dab07ed0
2 changed files with 22 additions and 3 deletions

View File

@ -319,10 +319,18 @@ public:
}
void AddRef() {
if (mRefCnt == PR_UINT16_MAX) {
NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
return;
}
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::Array", sizeof(*this));
}
void Release() {
if (mRefCnt == PR_UINT16_MAX) {
NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
return;
}
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsCSSValue::Array");
if (mRefCnt == 0)

View File

@ -157,11 +157,22 @@ public:
~Assertion();
void AddRef() { ++mRefCnt; }
void AddRef() {
if (mRefCnt == PR_UINT16_MAX) {
NS_WARNING("refcount overflow, leaking Assertion");
return;
}
++mRefCnt;
}
void Release(nsFixedSizeAllocator& aAllocator) {
if (mRefCnt == PR_UINT16_MAX) {
NS_WARNING("refcount overflow, leaking Assertion");
return;
}
if (--mRefCnt == 0)
Destroy(aAllocator, this); }
Destroy(aAllocator, this);
}
// For nsIRDFPurgeableDataSource
inline void Mark() { u.as.mMarked = PR_TRUE; }
@ -194,7 +205,7 @@ public:
// also shared between hash/as (see the union above)
// but placed after union definition to ensure that
// all 32-bit entries are long aligned
PRInt16 mRefCnt;
PRUint16 mRefCnt;
PRPackedBool mHashEntry;
private: