Bug 1240766 - Fix startup crash in Geolocation::Init() when principal URI is null r=jdm
authorTim Taubert <tim@timtaubert.de>
Tue, 19 Jan 2016 22:06:01 +0100
changeset 280792 56c7becfd682f0bb3cebfb5a5f3a41945e69ea7b
parent 280791 cbb0ad1e211825863b355d0b9ace98b373268bb3
child 280793 0c3fe09df5f10abe8bb6b2c82fe80bb4591d0de9
push id29922
push usercbook@mozilla.com
push dateThu, 21 Jan 2016 10:51:00 +0000
treeherdermozilla-central@977d78a8dd78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs1240766
milestone46.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 1240766 - Fix startup crash in Geolocation::Init() when principal URI is null r=jdm
dom/geolocation/nsGeolocation.cpp
--- a/dom/geolocation/nsGeolocation.cpp
+++ b/dom/geolocation/nsGeolocation.cpp
@@ -1250,29 +1250,31 @@ Geolocation::Init(nsIDOMWindow* aContent
                                   /* use capture */ true,
                                   /* wants untrusted */ false);
     }
 
     nsCOMPtr<nsIURI> uri;
     nsresult rv = mPrincipal->GetURI(getter_AddRefs(uri));
     NS_ENSURE_SUCCESS(rv, rv);
 
-    bool isHttp;
-    rv = uri->SchemeIs("http", &isHttp);
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (uri) {
+      bool isHttp;
+      rv = uri->SchemeIs("http", &isHttp);
+      NS_ENSURE_SUCCESS(rv, rv);
 
-    bool isHttps;
-    rv = uri->SchemeIs("https", &isHttps);
-    NS_ENSURE_SUCCESS(rv, rv);
+      bool isHttps;
+      rv = uri->SchemeIs("https", &isHttps);
+      NS_ENSURE_SUCCESS(rv, rv);
 
-    // Store the protocol to send via telemetry later.
-    if (isHttp) {
-      mProtocolType = ProtocolType::HTTP;
-    } else if (isHttps) {
-      mProtocolType = ProtocolType::HTTPS;
+      // Store the protocol to send via telemetry later.
+      if (isHttp) {
+        mProtocolType = ProtocolType::HTTP;
+      } else if (isHttps) {
+        mProtocolType = ProtocolType::HTTPS;
+      }
     }
   }
 
   // If no aContentDom was passed into us, we are being used
   // by chrome/c++ and have no mOwner, no mPrincipal, and no need
   // to prompt.
   mService = nsGeolocationService::GetGeolocationService();
   if (mService) {