From 5af218e201ef02ff9b1f039b862118bfc6f371f3 Mon Sep 17 00:00:00 2001 From: "locka%iol.ie" Date: Mon, 3 Dec 2001 12:42:49 +0000 Subject: [PATCH] Add code to nullify pointers and do extra checks to catch docshell crashes most likely caused by bad weak references. b=67721 r=rpotts@netscape.com sr=mscott@netscape.com git-svn-id: svn://10.0.0.236/trunk@109526 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDSURIContentListener.cpp | 4 +++- mozilla/docshell/base/nsDocShell.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mozilla/docshell/base/nsDSURIContentListener.cpp b/mozilla/docshell/base/nsDSURIContentListener.cpp index 7014c9e1e62..ca292ec0c13 100644 --- a/mozilla/docshell/base/nsDSURIContentListener.cpp +++ b/mozilla/docshell/base/nsDSURIContentListener.cpp @@ -46,6 +46,7 @@ nsDSURIContentListener::Init() { nsresult rv = NS_OK; mCatMgr = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); return rv; } @@ -111,6 +112,7 @@ nsDSURIContentListener::DoContent(const char* aContentType, if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) { nsCOMPtr domWindow = do_GetInterface(NS_STATIC_CAST(nsIDocShell*, mDocShell)); + NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE); domWindow->Focus(); } @@ -162,7 +164,7 @@ nsDSURIContentListener::CanHandleContent(const char* aContentType, *aCanHandleContent = PR_FALSE; - if (aContentType) + if (aContentType && mCatMgr) { nsXPIDLCString value; rv = mCatMgr->GetCategoryEntry("Gecko-Content-Viewers", diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index a5ef98594a1..4bdda9eda5c 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -2506,6 +2506,7 @@ nsDocShell::Destroy() if (mContentListener) { mContentListener->DocShell(nsnull); + mContentListener->SetParentContentListener(nsnull); NS_RELEASE(mContentListener); }