Bug 1187217 - Fix deref nullptr loadInfo in nsDocShell::LoadStream. r=bz
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Fri, 24 Jul 2015 12:15:14 -0700
changeset 254658 e7ca539c1cbb5fa6a4a6b5aa11f43cbf5f394b9f
parent 254657 5a03eaa2db9f8b30175ade6c6bab428076005b22
child 254659 27ae736ef960c2f0f52ab289554cf6af3ed02721
push id29108
push userryanvm@gmail.com
push dateMon, 27 Jul 2015 14:12:01 +0000
treeherdermozilla-central@27ae736ef960 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1187217
milestone42.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 1187217 - Fix deref nullptr loadInfo in nsDocShell::LoadStream. r=bz
docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -1705,30 +1705,32 @@ nsDocShell::LoadStream(nsIInputStream* a
     // For now, just use a bogus protocol called "internal"
     rv = uri->SetSpec(NS_LITERAL_CSTRING("internal:load-stream"));
     if (NS_FAILED(rv)) {
       return rv;
     }
   }
 
   uint32_t loadType = LOAD_NORMAL;
+  nsCOMPtr<nsIPrincipal> requestingPrincipal;
   if (aLoadInfo) {
     nsDocShellInfoLoadType lt = nsIDocShellLoadInfo::loadNormal;
     (void)aLoadInfo->GetLoadType(&lt);
     // Get the appropriate LoadType from nsIDocShellLoadInfo type
     loadType = ConvertDocShellLoadInfoToLoadType(lt);
+  
+    nsCOMPtr<nsISupports> owner;
+    aLoadInfo->GetOwner(getter_AddRefs(owner));
+    requestingPrincipal = do_QueryInterface(owner);
   }
 
   NS_ENSURE_SUCCESS(Stop(nsIWebNavigation::STOP_NETWORK), NS_ERROR_FAILURE);
 
   mLoadType = loadType;
 
-  nsCOMPtr<nsISupports> owner;
-  aLoadInfo->GetOwner(getter_AddRefs(owner));
-  nsCOMPtr<nsIPrincipal> requestingPrincipal = do_QueryInterface(owner);
   if (!requestingPrincipal) {
     requestingPrincipal = nsContentUtils::GetSystemPrincipal();
   }
 
   // build up a channel for this stream.
   nsCOMPtr<nsIChannel> channel;
   nsresult rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
                                          uri,