diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 0ad33fe91d99..923ec8248b48 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -5500,7 +5500,10 @@ nsDocShell::GetCurrentDocumentOwner(nsISupports ** aOwner) } //-- Get the document's principal - *aOwner = document->GetPrincipal(); + if (document) { + *aOwner = document->GetPrincipal(); + } + NS_IF_ADDREF(*aOwner); }