From 6230b4eb2e7e31a84547d45f8055850586d8df02 Mon Sep 17 00:00:00 2001 From: "reed%reedloden.com" Date: Sat, 8 Mar 2008 13:21:25 +0000 Subject: [PATCH] Bug 393432 - "Firefox crashes sometimes if you click the back button on www.userfriendly.org [@ DummyParserRequest::Cancel 334d84da]" (Store the sink in a nsWeakPtr and verify it is still valid before using) [p=colin@theblakes.com (Colin Blake) r=jst sr=bzbarsky a=ss] git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@247396 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/document/src/nsHTMLContentSink.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 4dbf12dd39d..dbf5ce294f7 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -458,7 +458,7 @@ protected: nsCOMPtr mLoadGroup; - nsIHTMLContentSink* mSink; // Weak reference + nsWeakPtr mSink; // Weak reference public: static nsresult @@ -668,7 +668,7 @@ DummyParserRequest::DummyParserRequest(nsIHTMLContentSink* aSink) "unable to create about:parser-dummy-request"); } - mSink = aSink; + mSink = do_GetWeakReference(aSink); } @@ -684,9 +684,13 @@ DummyParserRequest::Cancel(nsresult status) { // Cancel parser nsresult rv = NS_OK; - HTMLContentSink* sink = NS_STATIC_CAST(HTMLContentSink*, mSink); - if ((sink) && (sink->mParser)) { - sink->mParser->CancelParsingEvents(); + nsCOMPtr sink = do_QueryReferent(mSink); + if (sink) { + nsIHTMLContentSink* actualSink = sink; + HTMLContentSink* htmlContentSink = NS_STATIC_CAST(HTMLContentSink*, actualSink); + if (htmlContentSink->mParser) { + htmlContentSink->mParser->CancelParsingEvents(); + } } return rv; }