Bug 1302658 - substitute null checks with NS_ENSURE_TRUE. r=baku
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Wed, 14 Sep 2016 12:15:01 +0300
changeset 355161 bd37ea2f83d30f87940378c47f7f3cdd61d675bc
parent 355160 d38b840099f21f74162f306905a3303bed359f9e
child 355162 b9c4a0402a0a90ff4ef6223fcd2fa92422f8bf44
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1302658
milestone51.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 1302658 - substitute null checks with NS_ENSURE_TRUE. r=baku MozReview-Commit-ID: GQmfWrmhKNg
dom/base/nsScriptLoader.cpp
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/base/nsScriptLoader.cpp
@@ -1185,16 +1185,17 @@ nsScriptLoader::InstantiateModuleTree(ns
   return true;
 }
 
 nsresult
 nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType,
                           bool aScriptFromHead)
 {
   MOZ_ASSERT(aRequest->IsLoading());
+  NS_ENSURE_TRUE(mDocument, NS_ERROR_NULL_POINTER);
 
   // If this document is sandboxed without 'allow-scripts', abort.
   if (mDocument->HasScriptsBlockedBySandbox()) {
     return NS_OK;
   }
 
   if (aRequest->IsModuleRequest()) {
     // Check whether the module has been fetched or is currently being fetched,
@@ -1293,17 +1294,17 @@ nsScriptLoader::StartLoad(nsScriptLoadRe
   nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(httpChannel));
   if (timedChannel) {
     timedChannel->SetInitiatorType(NS_LITERAL_STRING("script"));
   }
 
   nsAutoPtr<mozilla::dom::SRICheckDataVerifier> sriDataVerifier;
   if (!aRequest->mIntegrity.IsEmpty()) {
     nsAutoCString sourceUri;
-    if (mDocument && mDocument->GetDocumentURI()) {
+    if (mDocument->GetDocumentURI()) {
       mDocument->GetDocumentURI()->GetAsciiSpec(sourceUri);
     }
     sriDataVerifier = new SRICheckDataVerifier(aRequest->mIntegrity, sourceUri,
                                                mReporter);
   }
 
   RefPtr<nsScriptLoadHandler> handler =
       new nsScriptLoadHandler(this, aRequest, sriDataVerifier.forget());
@@ -1524,17 +1525,17 @@ nsScriptLoader::ProcessScriptElement(nsI
         nsAutoString integrity;
         scriptContent->GetAttr(kNameSpaceID_None, nsGkAtoms::integrity,
                                integrity);
         if (!integrity.IsEmpty()) {
           MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug,
                  ("nsScriptLoader::ProcessScriptElement, integrity=%s",
                   NS_ConvertUTF16toUTF8(integrity).get()));
           nsAutoCString sourceUri;
-          if (mDocument && mDocument->GetDocumentURI()) {
+          if (mDocument->GetDocumentURI()) {
             mDocument->GetDocumentURI()->GetAsciiSpec(sourceUri);
           }
           SRICheck::IntegrityMetadata(integrity, sourceUri, mReporter,
                                       &sriMetadata);
         }
       }
 
       request = CreateLoadRequest(scriptKind, aElement, version, ourCORSMode,