Support non-flat strings in Any_getelem and Any_setelem.

This commit is contained in:
Andreas Gal
2008-08-11 16:12:52 -07:00
parent 689eaf0625
commit 6dc665b46c
2 changed files with 5 additions and 1 deletions

View File

@@ -302,6 +302,8 @@ jsval FASTCALL
js_Any_getelem(JSContext* cx, JSObject* obj, JSString* idstr)
{
jsval v;
if (!JSSTRING_IS_FLAT(idstr) && !js_UndependString(cx, idstr))
return JSVAL_ERROR_COOKIE;
if (!OBJ_GET_PROPERTY(cx, obj, ATOM_TO_JSID(STRING_TO_JSVAL(idstr)), &v))
return JSVAL_ERROR_COOKIE;
return v;
@@ -310,6 +312,8 @@ js_Any_getelem(JSContext* cx, JSObject* obj, JSString* idstr)
bool FASTCALL
js_Any_setelem(JSContext* cx, JSObject* obj, JSString* idstr, jsval v)
{
if (!JSSTRING_IS_FLAT(idstr) && !js_UndependString(cx, idstr))
return false;
return OBJ_SET_PROPERTY(cx, obj, ATOM_TO_JSID(STRING_TO_JSVAL(idstr)), &v);
}