From 6c898aeb0931775ab0c0142947aded902ad119ca Mon Sep 17 00:00:00 2001 From: "scc%netscape.com" Date: Fri, 11 Feb 2000 01:59:55 +0000 Subject: [PATCH] bug #25621: shouldn't add a |NULL| atom to the hashtable. r=beard git-svn-id: svn://10.0.0.236/trunk@60411 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/ds/nsAtomTable.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mozilla/xpcom/ds/nsAtomTable.cpp b/mozilla/xpcom/ds/nsAtomTable.cpp index ec69c91278b..40383d81331 100644 --- a/mozilla/xpcom/ds/nsAtomTable.cpp +++ b/mozilla/xpcom/ds/nsAtomTable.cpp @@ -145,6 +145,7 @@ NS_COM nsIAtom* NS_NewAtom(const nsString& aString) } NS_COM nsIAtom* NS_NewAtom(const PRUnichar* us) + // Note: in a low memory condition, this routine could return |NULL| { if (nsnull == gAtomHashTable) { gAtomHashTable = PL_NewHashTable(8, (PLHashFunction) HashKey, @@ -161,9 +162,14 @@ NS_COM nsIAtom* NS_NewAtom(const PRUnichar* us) NS_IF_ADDREF(id); return id; } + AtomImpl* id = new(us, uslen) AtomImpl(); - PL_HashTableRawAdd(gAtomHashTable, hep, hashCode, id->mString, id); - NS_IF_ADDREF(id); + if ( id ) + { + PL_HashTableRawAdd(gAtomHashTable, hep, hashCode, id->mString, id); + NS_ADDREF(id); + } + return id; }