зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1479712 part 5 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in xpc::StackScopedClone. r=bholley
This commit is contained in:
Родитель
4cda94fb7d
Коммит
741c3a4130
|
@ -206,20 +206,13 @@ public:
|
||||||
* function returns, |val| is set to the result of the clone.
|
* function returns, |val| is set to the result of the clone.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
StackScopedClone(JSContext* cx, StackScopedCloneOptions& options,
|
StackScopedClone(JSContext* cx, StackScopedCloneOptions& options, HandleObject sourceScope,
|
||||||
MutableHandleValue val)
|
MutableHandleValue val)
|
||||||
{
|
{
|
||||||
StackScopedCloneData data(cx, &options);
|
StackScopedCloneData data(cx, &options);
|
||||||
{
|
{
|
||||||
// For parsing val we have to enter its realm.
|
// For parsing val we have to enter (a realm in) its compartment.
|
||||||
// (unless it's a primitive)
|
JSAutoRealm ar(cx, sourceScope);
|
||||||
Maybe<JSAutoRealmAllowCCW> ar;
|
|
||||||
if (val.isObject()) {
|
|
||||||
ar.emplace(cx, &val.toObject());
|
|
||||||
} else if (val.isString() && !JS_WrapValue(cx, val)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!data.Write(cx, val))
|
if (!data.Write(cx, val))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2967,10 +2967,13 @@ xpc::CloneInto(JSContext* aCx, HandleValue aValue, HandleValue aScope,
|
||||||
if (aOptions.isObject() && !options.Parse())
|
if (aOptions.isObject() && !options.Parse())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
js::AssertSameCompartment(aCx, aValue);
|
||||||
|
RootedObject sourceScope(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||||
|
|
||||||
{
|
{
|
||||||
JSAutoRealm ar(aCx, scope);
|
JSAutoRealm ar(aCx, scope);
|
||||||
aCloned.set(aValue);
|
aCloned.set(aValue);
|
||||||
if (!StackScopedClone(aCx, options, aCloned))
|
if (!StackScopedClone(aCx, options, sourceScope, aCloned))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2806,7 +2806,8 @@ CloneInto(JSContext* cx, JS::HandleValue vobj, JS::HandleValue vscope,
|
||||||
JS::HandleValue voptions, JS::MutableHandleValue rval);
|
JS::HandleValue voptions, JS::MutableHandleValue rval);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
StackScopedClone(JSContext* cx, StackScopedCloneOptions& options, JS::MutableHandleValue val);
|
StackScopedClone(JSContext* cx, StackScopedCloneOptions& options, JS::HandleObject sourceScope,
|
||||||
|
JS::MutableHandleValue val);
|
||||||
|
|
||||||
} /* namespace xpc */
|
} /* namespace xpc */
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче