From 48792ed797a0a7b4940f31c7ff41116ed1f96a48 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 23 Mar 2012 12:13:44 +0000 Subject: [PATCH] bug 737412 - handle null sizeOfEntryExcludingThis pointer within ns{T,Base}Hashtable SizeOfExcludingThis functions. r=jfkthame --- xpcom/glue/nsBaseHashtable.h | 15 ++++++++------- xpcom/glue/nsTHashtable.h | 7 +++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/xpcom/glue/nsBaseHashtable.h b/xpcom/glue/nsBaseHashtable.h index 6ab8590865a..a1a8146ba41 100644 --- a/xpcom/glue/nsBaseHashtable.h +++ b/xpcom/glue/nsBaseHashtable.h @@ -274,14 +274,15 @@ public: size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, nsMallocSizeOfFun mallocSizeOf, void *userArg = nsnull) { - if (IsInitialized()) { - s_SizeOfArgs args = { sizeOfEntryExcludingThis, userArg }; - return PL_DHashTableSizeOfExcludingThis(&this->mTable, - s_SizeOfStub, - mallocSizeOf, - &args); + if (!IsInitialized()) { + return 0; } - return 0; + if (sizeOfEntryExcludingThis) { + s_SizeOfArgs args = { sizeOfEntryExcludingThis, userArg }; + return PL_DHashTableSizeOfExcludingThis(&this->mTable, s_SizeOfStub, + mallocSizeOf, &args); + } + return PL_DHashTableSizeOfExcludingThis(&this->mTable, NULL, mallocSizeOf); } protected: diff --git a/xpcom/glue/nsTHashtable.h b/xpcom/glue/nsTHashtable.h index 762517fb0aa..e2a00135858 100644 --- a/xpcom/glue/nsTHashtable.h +++ b/xpcom/glue/nsTHashtable.h @@ -288,11 +288,14 @@ public: size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, nsMallocSizeOfFun mallocSizeOf, void *userArg = NULL) const { - if (IsInitialized()) { + if (!IsInitialized()) { + return 0; + } + if (sizeOfEntryExcludingThis) { s_SizeOfArgs args = { sizeOfEntryExcludingThis, userArg }; return PL_DHashTableSizeOfExcludingThis(&mTable, s_SizeOfStub, mallocSizeOf, &args); } - return 0; + return PL_DHashTableSizeOfExcludingThis(&mTable, NULL, mallocSizeOf); } #ifdef DEBUG