Bug 1104193 - nullcheck for the principal in nsContentUtils::GetUTFOrigin(), r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 24 Nov 2014 20:54:59 +0100
changeset 217174 b66c71e822ca0da883458b9ae1491414d6c869b7
parent 217173 2b63fa9da2010fc86e3d0024bff779091a7e9633
child 217175 9a00da3709395e699a9d006916dedcb42632422a
push id52242
push useramarchesini@mozilla.com
push dateMon, 24 Nov 2014 19:55:25 +0000
treeherdermozilla-inbound@b66c71e822ca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1104193
milestone36.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 1104193 - nullcheck for the principal in nsContentUtils::GetUTFOrigin(), r=smaug
dom/base/nsContentUtils.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -5825,22 +5825,24 @@ nsContentUtils::GetUTFOrigin(nsIURI* aUR
   NS_PRECONDITION(aURI, "missing uri");
 
   // For Blob URI we have to return the origin of page using its principal.
   nsCOMPtr<nsIURIWithPrincipal> uriWithPrincipal = do_QueryInterface(aURI);
   if (uriWithPrincipal) {
     nsCOMPtr<nsIPrincipal> principal;
     uriWithPrincipal->GetPrincipal(getter_AddRefs(principal));
 
-    nsCOMPtr<nsIURI> uri;
-    nsresult rv = principal->GetURI(getter_AddRefs(uri));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    if (uri && uri != aURI) {
-      return GetUTFOrigin(uri, aOrigin);
+    if (principal) {
+      nsCOMPtr<nsIURI> uri;
+      nsresult rv = principal->GetURI(getter_AddRefs(uri));
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      if (uri && uri != aURI) {
+        return GetUTFOrigin(uri, aOrigin);
+      }
     }
   }
 
   aOrigin.Truncate();
 
   nsCOMPtr<nsIURI> uri = NS_GetInnermostURI(aURI);
   NS_ENSURE_TRUE(uri, NS_ERROR_UNEXPECTED);