Bug 774708: Ensure sBluetoothEventObserverTable is valid before attempting to query observers, fixing a Bluetooth crash in emulator. r=qDot

This commit is contained in:
Marshall Culpepper 2012-07-17 09:44:20 -07:00
parent 82d9434006
commit b9d7c4b96d

View File

@ -75,6 +75,8 @@ RegisterBluetoothEventHandler(const nsCString& aNodeName,
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothEventObserverList *ol;
NS_ENSURE_TRUE(sBluetoothEventObserverTable, NS_ERROR_FAILURE);
if (!sBluetoothEventObserverTable->Get(aNodeName, &ol)) {
sBluetoothEventObserverTable->Put(aNodeName,
new BluetoothEventObserverList());
@ -90,6 +92,8 @@ UnregisterBluetoothEventHandler(const nsCString& aNodeName,
{
MOZ_ASSERT(NS_IsMainThread());
BluetoothEventObserverList *ol;
NS_ENSURE_TRUE(sBluetoothEventObserverTable, NS_ERROR_FAILURE);
if (!sBluetoothEventObserverTable->Get(aNodeName, &ol)) {
NS_WARNING("Node does not exist to remove BluetoothEventListener from!");
return NS_ERROR_FAILURE;