mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 04:27:41 +00:00
Bug 867459 - Fix webrtc rooting hazards r=terrence
This commit is contained in:
parent
94cf99a091
commit
f7cf050076
@ -825,11 +825,11 @@ nsresult
|
||||
PeerConnectionImpl::ConvertConstraints(
|
||||
const JS::Value& aConstraints, MediaConstraints* aObj, JSContext* aCx)
|
||||
{
|
||||
JS::Value mandatory, optional;
|
||||
JSObject& constraints = aConstraints.toObject();
|
||||
JS::Rooted<JS::Value> mandatory(aCx), optional(aCx);
|
||||
JS::Rooted<JSObject*> constraints(aCx, &aConstraints.toObject());
|
||||
|
||||
// Mandatory constraints. Note that we only care if the constraint array exists
|
||||
if (!JS_GetProperty(aCx, &constraints, "mandatory", &mandatory)) {
|
||||
if (!JS_GetProperty(aCx, constraints, "mandatory", mandatory.address())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!mandatory.isNullOrUndefined()) {
|
||||
@ -837,14 +837,14 @@ PeerConnectionImpl::ConvertConstraints(
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSObject* opts = &mandatory.toObject();
|
||||
JS::Rooted<JSObject*> opts(aCx, &mandatory.toObject());
|
||||
JS::AutoIdArray mandatoryOpts(aCx, JS_Enumerate(aCx, opts));
|
||||
|
||||
// Iterate over each property.
|
||||
for (size_t i = 0; i < mandatoryOpts.length(); i++) {
|
||||
JS::Value option, optionName;
|
||||
if (!JS_GetPropertyById(aCx, opts, mandatoryOpts[i], &option) ||
|
||||
!JS_IdToValue(aCx, mandatoryOpts[i], &optionName) ||
|
||||
JS::Rooted<JS::Value> option(aCx), optionName(aCx);
|
||||
if (!JS_GetPropertyById(aCx, opts, mandatoryOpts[i], option.address()) ||
|
||||
!JS_IdToValue(aCx, mandatoryOpts[i], optionName.address()) ||
|
||||
// We only support boolean constraints for now.
|
||||
!option.isBoolean()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -859,7 +859,7 @@ PeerConnectionImpl::ConvertConstraints(
|
||||
}
|
||||
|
||||
// Optional constraints.
|
||||
if (!JS_GetProperty(aCx, &constraints, "optional", &optional)) {
|
||||
if (!JS_GetProperty(aCx, constraints, "optional", optional.address())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!optional.isNullOrUndefined()) {
|
||||
@ -867,26 +867,26 @@ PeerConnectionImpl::ConvertConstraints(
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSObject* array = &optional.toObject();
|
||||
JS::Rooted<JSObject*> array(aCx, &optional.toObject());
|
||||
uint32_t length;
|
||||
if (!JS_GetArrayLength(aCx, array, &length)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
JS::Value element;
|
||||
if (!JS_GetElement(aCx, array, i, &element) ||
|
||||
JS::Rooted<JS::Value> element(aCx);
|
||||
if (!JS_GetElement(aCx, array, i, element.address()) ||
|
||||
!element.isObject()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JSObject* opts = &element.toObject();
|
||||
JS::Rooted<JSObject*> opts(aCx, &element.toObject());
|
||||
JS::AutoIdArray optionalOpts(aCx, JS_Enumerate(aCx, opts));
|
||||
// Expect one property per entry.
|
||||
if (optionalOpts.length() != 1) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JS::Value option, optionName;
|
||||
if (!JS_GetPropertyById(aCx, opts, optionalOpts[0], &option) ||
|
||||
!JS_IdToValue(aCx, optionalOpts[0], &optionName)) {
|
||||
JS::Rooted<JS::Value> option(aCx), optionName(aCx);
|
||||
if (!JS_GetPropertyById(aCx, opts, optionalOpts[0], option.address()) ||
|
||||
!JS_IdToValue(aCx, optionalOpts[0], optionName.address())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Ignore constraints other than boolean, as that's all we support.
|
||||
|
Loading…
x
Reference in New Issue
Block a user