Bug 1369246 - Check if window pointer is null before attempting to call a method. r=baku
authorOriol <oriol-bugzilla@hotmail.com>
Thu, 01 Jun 2017 06:45:00 -0400
changeset 412322 c52cd79ee39d895b4bd607b1c28b94a3d5b8d70b
parent 412321 26e9faf36fc093367053243daf9ff3a1663dcdd9
child 412323 65fcedb6c1f8ff440941774d47cb2a7734f80222
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1369246
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1369246 - Check if window pointer is null before attempting to call a method. r=baku
dom/base/nsContentUtils.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -4444,22 +4444,23 @@ nsContentUtils::MatchElementId(nsIConten
 nsIDocument*
 nsContentUtils::GetSubdocumentWithOuterWindowId(nsIDocument *aDocument,
                                                 uint64_t aOuterWindowId)
 {
   if (!aDocument || !aOuterWindowId) {
     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.
     return foundDoc;
   }
 
   return nullptr;
 }