Bug 1537883 - Silently fail in case aPrincipal is null within SpeculativeConnectInternal. r=valentin,gijs a=pascalc
authorChristoph Kerschbaumer <ckerschb@christophkerschbaumer.com>
Fri, 29 Mar 2019 13:30:49 +0100
changeset 525893 cba236106e276ca96713e2ccd921f59f9139a589
parent 525892 10df2c9f7ce4c076dc4d6d7db9a1b8af23da8f2b
child 525894 626d4588cc90b132a7005c700a2b094c01a10267
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin, gijs, pascalc
bugs1537883
milestone67.0
Bug 1537883 - Silently fail in case aPrincipal is null within SpeculativeConnectInternal. r=valentin,gijs a=pascalc
netwerk/base/nsIOService.cpp
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -1758,16 +1758,23 @@ nsresult nsIOService::SpeculativeConnect
   nsresult rv;
   nsCOMPtr<nsIProtocolProxyService> pps =
       do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIPrincipal> loadingPrincipal = aPrincipal;
 
   MOZ_ASSERT(aPrincipal, "We expect passing a principal here.");
+  if (!aPrincipal) {
+    // Bug 1537883, fail silently in case aPrincipal is null rather
+    // than having the browser crash because we cannot create a
+    // loadInfo without a principal. Within Bug 1539853 we should
+    // resolve why aPrincipal is null here and remove the silent fail.
+    return NS_OK;
+  }
 
   // dummy channel used to create a TCP connection.
   // we perform security checks on the *real* channel, responsible
   // for any network loads. this real channel just checks the TCP
   // pool if there is an available connection created by the
   // channel we create underneath - hence it's safe to use
   // the systemPrincipal as the loadingPrincipal for this channel.
   nsCOMPtr<nsIChannel> channel;