Bug 1369246 - Check if window pointer is null before attempting to call a method. r=baku

This commit is contained in:
Oriol 2017-06-01 06:45:00 -04:00
parent c04074e14f
commit ece0618ecc

View File

@ -4449,12 +4449,13 @@ nsContentUtils::GetSubdocumentWithOuterWindowId(nsIDocument *aDocument,
return nullptr;
}
nsCOMPtr<nsPIDOMWindowOuter> window = nsGlobalWindow::GetOuterWindowWithId(aOuterWindowId)->AsOuter();
RefPtr<nsGlobalWindow> window = nsGlobalWindow::GetOuterWindowWithId(aOuterWindowId);
if (!window) {
return nullptr;
}
nsCOMPtr<nsIDocument> foundDoc = window->GetDoc();
nsCOMPtr<nsPIDOMWindowOuter> outerWindow = window->AsOuter();
nsCOMPtr<nsIDocument> foundDoc = outerWindow->GetDoc();
if (nsContentUtils::ContentIsCrossDocDescendantOf(foundDoc, aDocument)) {
// Note that ContentIsCrossDocDescendantOf will return true if
// foundDoc == aDocument.