Bug 1143925 - Avoid crash for HFP/A2DP manager during restart daemon. r=tzimmermann, a=bajaj
authorShawn Huang <shuang@mozilla.com>
Thu, 30 Apr 2015 07:05:00 -0400
changeset 238308 15cf85aa64aaa35ea3ee5aa1618cf0a0398d3a77
parent 238307 08d56e7f909befae15acead5e9ea19d6333651f4
child 238309 b76acb0d1045390517c9ca58e69ddb96c325ac32
push id561
push userryanvm@gmail.com
push dateTue, 05 May 2015 01:51:32 +0000
treeherdermozilla-b2g37_v2_2@15cf85aa64aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstzimmermann, bajaj
bugs1143925
milestone37.0
Bug 1143925 - Avoid crash for HFP/A2DP manager during restart daemon. r=tzimmermann, a=bajaj
dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
--- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
@@ -529,16 +529,17 @@ BluetoothA2dpManager::Connect(const nsAS
 
   sBtA2dpInterface->Connect(aDeviceAddress, new ConnectResultHandler());
 }
 
 void
 BluetoothA2dpManager::OnDisconnectError()
 {
   MOZ_ASSERT(NS_IsMainThread());
+  NS_ENSURE_TRUE_VOID(mController);
 
   mController->NotifyCompletion(NS_LITERAL_STRING(ERR_DISCONNECTION_FAILED));
 }
 
 class BluetoothA2dpManager::DisconnectResultHandler MOZ_FINAL
   : public BluetoothA2dpResultHandler
 {
 public:
@@ -573,17 +574,19 @@ BluetoothA2dpManager::Disconnect(Bluetoo
   }
 
   MOZ_ASSERT(!mDeviceAddress.IsEmpty());
 
   mController = aController;
 
   if (!sBtA2dpInterface) {
     BT_LOGR("sBluetoothA2dpInterface is null");
-    aController->NotifyCompletion(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
+    if (aController) {
+      aController->NotifyCompletion(NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
+    }
     return;
   }
 
   sBtA2dpInterface->Disconnect(mDeviceAddress, new DisconnectResultHandler());
 }
 
 void
 BluetoothA2dpManager::OnConnect(const nsAString& aErrorStr)
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -1227,16 +1227,17 @@ BluetoothHfpManager::Connect(const nsASt
   sBluetoothHfpInterface->Connect(mDeviceAddress,
                                   new ConnectResultHandler(this));
 }
 
 void
 BluetoothHfpManager::OnDisconnectError()
 {
   MOZ_ASSERT(NS_IsMainThread());
+  NS_ENSURE_TRUE_VOID(mController);
 
   mController->NotifyCompletion(NS_LITERAL_STRING(ERR_CONNECTION_FAILED));
 }
 
 class BluetoothHfpManager::DisconnectResultHandler MOZ_FINAL
   : public BluetoothHandsfreeResultHandler
 {
 public: