Bug 791945 - Final version: Assertion failed when checking type of propertychanged message, r=echou
authorGina Yeh <gyeh@mozilla.com>
Wed, 19 Sep 2012 11:19:45 +0800
changeset 107455 20ba45df0a7372fff61dd3ec09b1167ad59066ad
parent 107454 1c7689d7feb60b761a0dddcca71638e695b63329
child 107456 c9c8d79d3419d833b4474b00f9be706fbf6af14e
push idunknown
push userunknown
push dateunknown
reviewersechou
bugs791945
milestone18.0a1
Bug 791945 - Final version: Assertion failed when checking type of propertychanged message, r=echou
dom/bluetooth/BluetoothAdapter.cpp
dom/bluetooth/BluetoothDevice.cpp
--- a/dom/bluetooth/BluetoothAdapter.cpp
+++ b/dom/bluetooth/BluetoothAdapter.cpp
@@ -302,24 +302,23 @@ BluetoothAdapter::Notify(const Bluetooth
 
     nsCOMPtr<nsIDOMBluetoothDeviceEvent> e = do_QueryInterface(event);
     e->InitBluetoothDeviceEvent(NS_LITERAL_STRING("devicecreated"),
                                 false, false, device);
     e->SetTrusted(true);
     bool dummy;
     DispatchEvent(event, &dummy);
   } else if (aData.name().EqualsLiteral("PropertyChanged")) {
-    // Get BluetoothNamedValue, make sure array length is 1
+    NS_ASSERTION(aData.value().type() == BluetoothValue::TArrayOfBluetoothNamedValue,
+                 "PropertyChanged: Invalid value type");
     arr = aData.value().get_ArrayOfBluetoothNamedValue();
 
     NS_ASSERTION(arr.Length() == 1, "Got more than one property in a change message!");
-    NS_ASSERTION(arr[0].value().type() == BluetoothValue::TArrayOfBluetoothNamedValue,
-                 "PropertyChanged: Invalid value type");
+    BluetoothNamedValue v = arr[0];
 
-    BluetoothNamedValue v = arr[0];
     SetPropertyByValue(v);
     nsRefPtr<BluetoothPropertyEvent> e = BluetoothPropertyEvent::Create(v.name());
     e->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("propertychanged"));
   } else {
 #ifdef DEBUG
     nsCString warningMsg;
     warningMsg.AssignLiteral("Not handling adapter signal: ");
     warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
--- a/dom/bluetooth/BluetoothDevice.cpp
+++ b/dom/bluetooth/BluetoothDevice.cpp
@@ -180,18 +180,22 @@ BluetoothDevice::Create(nsPIDOMWindow* a
 
   return device.forget();
 }
 
 void
 BluetoothDevice::Notify(const BluetoothSignal& aData)
 {
   if (aData.name().EqualsLiteral("PropertyChanged")) {
-    // Get BluetoothNamedValue, make sure array length is 1
-    BluetoothNamedValue v = aData.value().get_ArrayOfBluetoothNamedValue()[0];
+    NS_ASSERTION(aData.value().type() == BluetoothValue::TArrayOfBluetoothNamedValue,
+                 "PropertyChanged: Invalid value type");
+    InfallibleTArray<BluetoothNamedValue> arr = aData.value().get_ArrayOfBluetoothNamedValue();
+
+    NS_ASSERTION(arr.Length() == 1, "Got more than one property in a change message!");
+    BluetoothNamedValue v = arr[0];
     nsString name = v.name();
 
     if (name.EqualsLiteral("Connected")) {
       bool isConnected = v.value();
       nsRefPtr<nsDOMEvent> event = new nsDOMEvent(nullptr, nullptr);
       nsresult rv;
       if (isConnected) {
         rv = event->InitEvent(NS_LITERAL_STRING("connected"), false, false);