mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 783431 - Fix js array initialization for bluetooth and telephony; r=mrbkap
This commit is contained in:
parent
955d0d468f
commit
a72c6b98bc
@ -34,7 +34,7 @@ mozilla::dom::bluetooth::StringArrayToJSArray(JSContext* aCx, JSObject* aGlobal,
|
||||
} else {
|
||||
uint32_t valLength = aSourceArray.Length();
|
||||
mozilla::ScopedDeleteArray<jsval> valArray(new jsval[valLength]);
|
||||
JS::AutoArrayRooter tvr(aCx, valLength, valArray);
|
||||
JS::AutoArrayRooter tvr(aCx, 0, valArray);
|
||||
for (PRUint32 index = 0; index < valLength; index++) {
|
||||
JSString* s = JS_NewUCStringCopyN(aCx, aSourceArray[index].BeginReading(),
|
||||
aSourceArray[index].Length());
|
||||
@ -43,6 +43,7 @@ mozilla::dom::bluetooth::StringArrayToJSArray(JSContext* aCx, JSObject* aGlobal,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
valArray[index] = STRING_TO_JSVAL(s);
|
||||
tvr.changeLength(index + 1);
|
||||
}
|
||||
arrayObj = JS_NewArrayObject(aCx, valLength, valArray);
|
||||
}
|
||||
@ -83,14 +84,14 @@ mozilla::dom::bluetooth::BluetoothDeviceArrayToJSArray(JSContext* aCx, JSObject*
|
||||
} else {
|
||||
uint32_t valLength = aSourceArray.Length();
|
||||
mozilla::ScopedDeleteArray<jsval> valArray(new jsval[valLength]);
|
||||
JS::AutoArrayRooter tvr(aCx, valLength, valArray);
|
||||
JS::AutoArrayRooter tvr(aCx, 0, valArray);
|
||||
for (PRUint32 index = 0; index < valLength; index++) {
|
||||
nsISupports* obj = aSourceArray[index]->ToISupports();
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(aCx, aGlobal, obj, &valArray[index]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
tvr.changeLength(index + 1);
|
||||
}
|
||||
|
||||
arrayObj = JS_NewArrayObject(aCx, valLength, valArray);
|
||||
}
|
||||
|
||||
|
@ -56,14 +56,14 @@ nsTArrayToJSArray(JSContext* aCx, JSObject* aGlobal,
|
||||
} else {
|
||||
uint32_t valLength = aSourceArray.Length();
|
||||
mozilla::ScopedDeleteArray<jsval> valArray(new jsval[valLength]);
|
||||
JS::AutoArrayRooter tvr(aCx, valLength, valArray);
|
||||
JS::AutoArrayRooter tvr(aCx, 0, valArray);
|
||||
for (PRUint32 index = 0; index < valLength; index++) {
|
||||
nsISupports* obj = aSourceArray[index]->ToISupports();
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(aCx, aGlobal, obj, &valArray[index]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
tvr.changeLength(index + 1);
|
||||
}
|
||||
|
||||
arrayObj = JS_NewArrayObject(aCx, valLength, valArray);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user