diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index 9dbbf105207..b6e115a0d63 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -297,14 +297,16 @@ RemoveObjectEntry(PLDHashTable& table, nsISupports* aKey) static nsresult SetOrRemoveObject(PLDHashTable& table, nsISupports* aKey, nsISupports* aValue) { - // lazily create the table, but don't create it just to remove a - // non-existent element! - if (!table.ops && aValue) - PL_DHashTableInit(&table, &ObjectTableOps, nsnull, - sizeof(ObjectEntry), 16); - - if (aValue) + if (aValue) { + // lazily create the table, but only when adding elements + if (!table.ops && + !PL_DHashTableInit(&table, &ObjectTableOps, nsnull, + sizeof(ObjectEntry), 16)) { + table.ops = nsnull; + return NS_ERROR_OUT_OF_MEMORY; + } return AddObjectEntry(table, aKey, aValue); + } // no value, so remove the key from the table if (table.ops)