Bug 1143925 - Avoid crash for HFP/A2DP manager during restart daemon. r=tzimmermann, a=bajaj
--- 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: