Bug 1339372 - Abort during geolocation request when system DBus is not available; r=kanru
authorJan Horak <jhorak@redhat.com>
Thu, 16 Feb 2017 09:18:36 +0100
changeset 485441 32c6b4f77110e43b1fe74cb1f81d09c3aad6ffad
parent 485440 43e48c2dde488bbfe437289164265a9a7c5300fa
child 485442 7ff2deda019f67d97e1ff062f41809493922c95c
push id45733
push useraklotz@mozilla.com
push dateThu, 16 Feb 2017 17:45:58 +0000
reviewerskanru
bugs1339372
milestone54.0a1
Bug 1339372 - Abort during geolocation request when system DBus is not available; r=kanru Under some special circumstances the system DBus is not available (for example in sandboxed environment). This caused a crash during obtaining list of nearby wifi APs for determining user location. This patch check result of dbus_bus_get() to avoid aborting. MozReview-Commit-ID: LunRRdQQ4eL *** Added braces
netwerk/wifi/nsWifiScannerDBus.cpp
--- a/netwerk/wifi/nsWifiScannerDBus.cpp
+++ b/netwerk/wifi/nsWifiScannerDBus.cpp
@@ -10,30 +10,35 @@ namespace mozilla {
 
 nsWifiScannerDBus::nsWifiScannerDBus(nsCOMArray<nsWifiAccessPoint> *aAccessPoints)
 : mAccessPoints(aAccessPoints)
 {
   MOZ_ASSERT(mAccessPoints);
 
   mConnection =
     already_AddRefed<DBusConnection>(dbus_bus_get(DBUS_BUS_SYSTEM, nullptr));
-  MOZ_ASSERT(mConnection);
-  dbus_connection_set_exit_on_disconnect(mConnection, false);
+
+  if (mConnection) {
+    dbus_connection_set_exit_on_disconnect(mConnection, false);
+  }
 
   MOZ_COUNT_CTOR(nsWifiScannerDBus);
 }
 
 nsWifiScannerDBus::~nsWifiScannerDBus()
 {
   MOZ_COUNT_DTOR(nsWifiScannerDBus);
 }
 
 nsresult
 nsWifiScannerDBus::Scan()
 {
+  if (!mConnection) {
+    return NS_ERROR_NOT_AVAILABLE;
+  }
   return SendMessage("org.freedesktop.NetworkManager",
                      "/org/freedesktop/NetworkManager",
                      "GetDevices");
 }
 
 nsresult
 nsWifiScannerDBus::SendMessage(const char* aInterface,
                                const char* aPath,