From 9352850db6ecfe01783daec36b6b27cf1c726e88 Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Fri, 17 Feb 2006 23:41:44 +0000 Subject: [PATCH] Change finalization of event listener manager hash to deal with interactions with preserved wrapper table and dangling pointers. b=325279 r=bzbarsky sr=jst git-svn-id: svn://10.0.0.236/trunk@190421 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsContentUtils.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/mozilla/content/base/src/nsContentUtils.cpp b/mozilla/content/base/src/nsContentUtils.cpp index 1203e8f3cce..2c3a6d8985d 100644 --- a/mozilla/content/base/src/nsContentUtils.cpp +++ b/mozilla/content/base/src/nsContentUtils.cpp @@ -643,18 +643,16 @@ nsContentUtils::Shutdown() // See comment above. - // Copy the ops out of the hash table - PLDHashTableOps hash_table_ops = *sEventListenerManagersHash.ops; + // However, we have to handle this table differently. If it still + // has entries, we want to leak it too, so that we can keep it alive + // in case any elements are destroyed. Because if they are, we need + // their event listener managers to be destroyed too, or otherwise + // it could leave dangling references in DOMClassInfo's preserved + // wrapper table. - // Set the clearEntry hook to be a nop - hash_table_ops.clearEntry = NopClearEntry; - - // Set the ops in the hash table to be the new ops - sEventListenerManagersHash.ops = &hash_table_ops; - - PL_DHashTableFinish(&sEventListenerManagersHash); - - sEventListenerManagersHash.ops = nsnull; + if (sEventListenerManagersHash.entryCount == 0) { + PL_DHashTableFinish(&sEventListenerManagersHash); + } } }