Bug 1104193 - nullcheck in nsContentUtils::GetASCIIOrigin, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 24 Nov 2014 21:43:11 +0100
changeset 217176 0a6d23163848d24bc35fbb8e380a53e86aa62615
parent 217175 9a00da3709395e699a9d006916dedcb42632422a
child 217177 b688a0a2650925c6dfcfc9490fcfc88a4909249a
push id52244
push useramarchesini@mozilla.com
push dateMon, 24 Nov 2014 20:44:27 +0000
treeherdermozilla-inbound@0a6d23163848 [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 in nsContentUtils::GetASCIIOrigin, r=smaug
dom/base/nsContentUtils.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -5752,22 +5752,24 @@ nsContentUtils::GetASCIIOrigin(nsIURI* a
   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 GetASCIIOrigin(uri, aOrigin);
+    if (principal) {
+      nsCOMPtr<nsIURI> uri;
+      nsresult rv = principal->GetURI(getter_AddRefs(uri));
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      if (uri && uri != aURI) {
+        return GetASCIIOrigin(uri, aOrigin);
+      }
     }
   }
 
   aOrigin.Truncate();
 
   nsCOMPtr<nsIURI> uri = NS_GetInnermostURI(aURI);
   NS_ENSURE_TRUE(uri, NS_ERROR_UNEXPECTED);