Bug 787581 - Fix nullptr access crash in BluetoothManager Destructor; r=echou
authorKyle Machulis <kyle@nonpolynomial.com>
Tue, 04 Sep 2012 10:29:06 -0700
changeset 104205 39152d29fd3dcd097f9f73e5f234cc48686815c6
parent 104204 c861b47cd0ff7cd0d0561496b2dab052236747ea
child 104206 8d9c80e2f95b529aabf480831429471e7784fd15
push id14392
push userkmachulis@mozilla.com
push dateTue, 04 Sep 2012 17:28:51 +0000
treeherdermozilla-inbound@39152d29fd3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechou
bugs787581
milestone18.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 787581 - Fix nullptr access crash in BluetoothManager Destructor; r=echou
dom/bluetooth/BluetoothManager.cpp
--- a/dom/bluetooth/BluetoothManager.cpp
+++ b/dom/bluetooth/BluetoothManager.cpp
@@ -159,31 +159,35 @@ BluetoothManager::FireEnabledDisabledEve
 BluetoothManager::BluetoothManager(nsPIDOMWindow *aWindow) :
   BluetoothPropertyContainer(BluetoothObjectType::TYPE_MANAGER),
   mEnabled(false)
 {
   BindToOwner(aWindow);
   mPath.AssignLiteral("/");
 
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-  obs->AddObserver(this, "mozsettings-changed", false);
+  if (obs) {
+    obs->AddObserver(this, "mozsettings-changed", false);
+  }
 }
 
 BluetoothManager::~BluetoothManager()
 {
   BluetoothService* bs = BluetoothService::Get();
   // We can be null on shutdown, where this might happen
   if (bs) {
     if (NS_FAILED(bs->UnregisterBluetoothSignalHandler(mPath, this))) {
       NS_WARNING("Failed to unregister object with observer!");
     }
   }
 
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-  obs->RemoveObserver(this, "mozsettings-changed");
+  if (obs) {
+    obs->RemoveObserver(this, "mozsettings-changed");
+  }
 }
 
 nsresult
 BluetoothManager::HandleMozsettingChanged(const PRUnichar* aData)
 {
   // The string that we're interested in will be a JSON string that looks like:
   //  {"key":"bluetooth.enabled","value":true}
   nsresult rv;