mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-10-13 15:34:37 +00:00
SpiderMonkey 38 removes the JS_LookupProperty{,ById} API. Refs #3708.
Use JS_GetProperty{,ById} instead.
Ensure that we break if someone tries to serialize a getter by using
something similar to what we used pre 47a03c3397.
https://bugzilla.mozilla.org/show_bug.cgi?id=1094176
This was SVN commit r17633.
This commit is contained in:
@@ -179,8 +179,8 @@ void CBinarySerializerScriptImpl::HandleScriptVal(JS::HandleValue val)
|
||||
if (hasCustomSerialize)
|
||||
{
|
||||
JS::RootedValue serialize(cx);
|
||||
if (!JS_LookupProperty(cx, obj, "Serialize", &serialize))
|
||||
throw PSERROR_Serialize_ScriptError("JS_LookupProperty failed");
|
||||
if (!JS_GetProperty(cx, obj, "Serialize", &serialize))
|
||||
throw PSERROR_Serialize_ScriptError("JS_GetProperty failed");
|
||||
|
||||
// If serialize is null, so don't serialize anything more
|
||||
if (!serialize.isNull())
|
||||
@@ -312,7 +312,14 @@ void CBinarySerializerScriptImpl::HandleScriptVal(JS::HandleValue val)
|
||||
|
||||
JS::RootedValue idval(cx);
|
||||
JS::RootedValue propval(cx);
|
||||
|
||||
|
||||
// Forbid getters, which might delete values and mess things up.
|
||||
JS::Rooted<JSPropertyDescriptor> desc(cx);
|
||||
if (!JS_GetPropertyDescriptorById(cx, obj, id, &desc))
|
||||
throw PSERROR_Serialize_ScriptError("JS_GetPropertyDescriptorById failed");
|
||||
if (desc.hasGetterObject())
|
||||
throw PSERROR_Serialize_ScriptError("Cannot serialize property getters");
|
||||
|
||||
// Get the property name as a string
|
||||
if (!JS_IdToValue(cx, id, &idval))
|
||||
throw PSERROR_Serialize_ScriptError("JS_IdToValue failed");
|
||||
@@ -322,10 +329,8 @@ void CBinarySerializerScriptImpl::HandleScriptVal(JS::HandleValue val)
|
||||
|
||||
ScriptString("prop name", idstr);
|
||||
|
||||
// Use LookupProperty instead of GetProperty to avoid the danger of getters
|
||||
// (they might delete values and trigger GC)
|
||||
if (!JS_LookupPropertyById(cx, obj, id, &propval))
|
||||
throw PSERROR_Serialize_ScriptError("JS_LookupPropertyById failed");
|
||||
if (!JS_GetPropertyById(cx, obj, id, &propval))
|
||||
throw PSERROR_Serialize_ScriptError("JS_GetPropertyById failed");
|
||||
|
||||
HandleScriptVal(propval);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user