Bug 1501498: Fix crash in AddonContentPolicy. r=baku a=RyanVM
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Thu, 25 Oct 2018 15:10:47 +0200
changeset 500885 a8a181f1095f6c8e6954fa8ed9a4c60ba6bbc755
parent 500884 38e139673b1933a7b950943ed997eab813924e05
child 500886 29af6b2cf6dc715f6cdc301549a0b2e0cf046b3b
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, RyanVM
bugs1501498
milestone64.0
Bug 1501498: Fix crash in AddonContentPolicy. r=baku a=RyanVM
toolkit/mozapps/extensions/AddonContentPolicy.cpp
--- a/toolkit/mozapps/extensions/AddonContentPolicy.cpp
+++ b/toolkit/mozapps/extensions/AddonContentPolicy.cpp
@@ -92,16 +92,21 @@ LogMessage(const nsAString &aMessage, ns
 // Content policy enforcement:
 
 NS_IMETHODIMP
 AddonContentPolicy::ShouldLoad(nsIURI* aContentLocation,
                                nsILoadInfo* aLoadInfo,
                                const nsACString& aMimeTypeGuess,
                                int16_t* aShouldLoad)
 {
+  if (!aContentLocation || !aLoadInfo) {
+    *aShouldLoad = REJECT_REQUEST;
+    return NS_ERROR_FAILURE;
+  }
+
   uint32_t contentType = aLoadInfo->GetExternalContentPolicyType();
   nsCOMPtr<nsIURI> requestOrigin;
   nsCOMPtr<nsIPrincipal> loadingPrincipal = aLoadInfo->LoadingPrincipal();
   if (loadingPrincipal) {
     loadingPrincipal->GetURI(getter_AddRefs(requestOrigin));
   }
 
   MOZ_ASSERT(contentType == nsContentUtils::InternalContentPolicyTypeToExternal(contentType),