From dfdc61ac704bcffe61883b031ece7e0705c1e5ae Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Wed, 8 Dec 2021 18:56:27 +0000 Subject: [Docshell] Close ContentViewer properly if initialization fails. --- docshell/base/nsDocShell.cpp | 4 ++++ layout/base/nsDocumentViewer.cpp | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index c40fbd7a10..5b89df5116 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -9353,7 +9353,11 @@ nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer) mContentViewer->SetNavigationTiming(mTiming); if (NS_FAILED(mContentViewer->Init(widget, bounds))) { + nsCOMPtr viewer = mContentViewer; + viewer->Close(nullptr); + viewer->Destroy(); mContentViewer = nullptr; + mCurrentURI = nullptr; NS_WARNING("ContentViewer Initialization failed"); return NS_ERROR_FAILURE; } diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index a0af38c289..ce8ab1c3d0 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1602,8 +1602,6 @@ DetachContainerRecurse(nsIDocShell *aShell) NS_IMETHODIMP nsDocumentViewer::Destroy() { - NS_ASSERTION(mDocument, "No document in Destroy()!"); - #ifdef NS_PRINTING // Here is where we check to see if the document was still being prepared // for printing when it was asked to be destroy from someone externally -- cgit v1.2.3