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
This commit is contained in:
scc%netscape.com
2000-02-11 01:59:55 +00:00
parent 11c3af9ebc
commit 6c898aeb09

View File

@@ -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;
}