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 225780 e84f980d638e
parent 225779 42f43b1c896e
child 225781 290442516a98
push id4014
push userryanvm@gmail.com
push date2014-10-22 23:37 +0000
treeherdermozilla-beta@27b0655c1385 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, lmandel
bugs1084513
milestone34.0
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
@@ -301,17 +301,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;
   }