From a2162b77a79f25b6444b9907eddccf17ac33be16 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Tue, 19 Jan 2016 22:06:01 +0100 Subject: [PATCH] Bug 1240766 - Fix startup crash in Geolocation::Init() when principal URI is null r=jdm --- dom/geolocation/nsGeolocation.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/dom/geolocation/nsGeolocation.cpp b/dom/geolocation/nsGeolocation.cpp index ba05b2d8e304..3919a94e3669 100644 --- a/dom/geolocation/nsGeolocation.cpp +++ b/dom/geolocation/nsGeolocation.cpp @@ -1255,19 +1255,21 @@ Geolocation::Init(nsIDOMWindow* aContentDom) 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; + } } }