Bug 1501498: Fix crash in AddonContentPolicy. r=baku
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Thu, 25 Oct 2018 15:10:47 +0200
changeset 491281 e8b53fa4ae7e8047eabaab6b2da701c209a74cba
parent 491280 1417a92298ff87a3b0f328566ed20b06cbcb1d65
child 491282 e55f02b20a9ced3c912ab4642c32a77e4337c11b
child 491318 37d240a1d498bd1662e0f9d6053ee75ccdb90786
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersbaku
bugs1501498
milestone65.0a1
Bug 1501498: Fix crash in AddonContentPolicy. r=baku
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),