Bug 1084513 - Add a null check on callingDoc before we try and get its principal. r=smaug, a=lmandel
authorTanvi Vyas <tvyas@mozilla.com>
Mon, 20 Oct 2014 12:43:41 -0700
changeset 233417 edf8cdca3a10c41e61a1f48d9c1599ea800aea3d
parent 233416 676409f0e83c5632d059e7b535554e35d437bd7a
child 233418 6dbac37df938bcf62cb1720c47b5686c08a1e273
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, lmandel
bugs1084513
milestone35.0a2
Bug 1084513 - Add a null check on callingDoc before we try and get its principal. r=smaug, a=lmandel
dom/xml/XMLDocument.cpp
--- a/dom/xml/XMLDocument.cpp
+++ b/dom/xml/XMLDocument.cpp
@@ -300,17 +300,17 @@ XMLDocument::Load(const nsAString& aUrl,
   }
 
   WarnOnceAbout(nsIDocument::eUseOfDOM3LoadMethod);
 
   nsCOMPtr<nsIDocument> callingDoc = GetEntryDocument();
   nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
 
   // The callingDoc's Principal and doc's Principal should be the same
-  if (callingDoc->NodePrincipal() != principal) {
+  if (callingDoc && (callingDoc->NodePrincipal() != principal)) {
     nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
                                     NS_LITERAL_CSTRING("DOM"),
                                     callingDoc,
                                     nsContentUtils::eDOM_PROPERTIES,
                                     "XMLDocumentLoadPrincipalMismatch");
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return false;
   }