Bug 1302658 - substitute null checks with NS_ENSURE_TRUE. r?baku draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Wed, 14 Sep 2016 12:15:01 +0300
changeset 413395 3addc6739f8bb0bda704f51a2ba9085d143f7b82
parent 413272 82d0a583a9a39bf0b0000bccbf6d5c9ec2596bcc
child 531231 5de8c950482c42ee1cc40c6219327d5f59a590f6
push id29433
push userbmo:bpostelnicu@mozilla.com
push dateWed, 14 Sep 2016 09:15:58 +0000
reviewersbaku
bugs1302658
milestone51.0a1
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,