From 00ff48fd86baf1acaa5cb11399448f145822fbe3 Mon Sep 17 00:00:00 2001 From: "peterv%propagandism.org" Date: Wed, 5 Dec 2007 00:29:13 +0000 Subject: [PATCH] Fix for bug 406684 (Memory leaks when content policies set properties of wrapped nodes). r/sr=sicking. git-svn-id: svn://10.0.0.236/trunk@240467 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsDocument.cpp | 7 +++++++ mozilla/dom/src/base/nsGlobalWindow.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 2f2a53448a8..c2fce3d4f5a 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -5583,6 +5583,13 @@ nsDocument::Destroy() mLayoutHistoryState = nsnull; nsContentList::OnDocumentDestroy(this); + + // XXX We really should let cycle collection do this, but that currently still + // leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684). + // When we start relying on cycle collection again we should remove the + // check for mScriptGlobalObject in AddReference. + delete mContentWrapperHash; + mContentWrapperHash = nsnull; } already_AddRefed diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index 21d1f027bbf..cd1906a9ab1 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -988,7 +988,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow) // Unlink any associated preserved wrapper. if (tmp->mDoc) { - tmp->mDoc->RemoveReference(tmp->mDoc.get()); + tmp->mDoc->RemoveReference(tmp); NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDoc) }