diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 2690725e507..5fb3d692f8f 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -921,6 +921,9 @@ NS_IMETHODIMP nsDocShell::FirePageHideNotification(PRBool aIsUnload) { if (mContentViewer && !mFiredUnloadEvent) { + // Keep an explicit reference since calling PageHide could release + // mContentViewer + nsCOMPtr kungFuDeathGrip(mContentViewer); mFiredUnloadEvent = PR_TRUE; mContentViewer->PageHide(aIsUnload); diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index b03a24a8d55..9300b28dac1 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -1240,6 +1240,9 @@ DocumentViewerImpl::PageHide(PRBool aIsUnload) if (!aIsUnload) return NS_OK; + // if Destroy() was called during OnPageHide(), mDocument is nsnull. + NS_ENSURE_STATE(mDocument); + // First, get the window from the document... nsPIDOMWindow *window = mDocument->GetWindow();