зеркало из https://github.com/mozilla/pjs.git
Fix SetFunctionSlot to cope with the second shawdowed arg or var (289094, r=shaver).
This commit is contained in:
Родитель
73bf0aa6a3
Коммит
517b250fd9
|
@ -479,9 +479,11 @@ SetFunctionSlot(JSContext *cx, JSObject *obj, JSPropertyOp setter, jsid id,
|
||||||
JSScope *scope;
|
JSScope *scope;
|
||||||
JSScopeProperty *sprop;
|
JSScopeProperty *sprop;
|
||||||
JSString *str;
|
JSString *str;
|
||||||
JSBool ok;
|
JSBool ok, done;
|
||||||
|
JSFunction *fun;
|
||||||
|
|
||||||
slot = (uintN) JSID_TO_INT(id);
|
slot = (uintN) JSID_TO_INT(id);
|
||||||
|
origobj = obj;
|
||||||
if (OBJ_GET_CLASS(cx, obj) != &js_FunctionClass) {
|
if (OBJ_GET_CLASS(cx, obj) != &js_FunctionClass) {
|
||||||
/*
|
/*
|
||||||
* Given a non-function object obj that has a function object in its
|
* Given a non-function object obj that has a function object in its
|
||||||
|
@ -492,7 +494,6 @@ SetFunctionSlot(JSContext *cx, JSObject *obj, JSPropertyOp setter, jsid id,
|
||||||
* function's "static property" names and arg or var names, believe it
|
* function's "static property" names and arg or var names, believe it
|
||||||
* or not.
|
* or not.
|
||||||
*/
|
*/
|
||||||
origobj = obj;
|
|
||||||
do {
|
do {
|
||||||
obj = OBJ_GET_PROTO(cx, obj);
|
obj = OBJ_GET_PROTO(cx, obj);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
|
@ -532,26 +533,46 @@ SetFunctionSlot(JSContext *cx, JSObject *obj, JSPropertyOp setter, jsid id,
|
||||||
* allocating a slot in obj to hold v.
|
* allocating a slot in obj to hold v.
|
||||||
*/
|
*/
|
||||||
ok = JS_TRUE;
|
ok = JS_TRUE;
|
||||||
JS_LOCK_OBJ(cx, obj);
|
done = JS_FALSE;
|
||||||
scope = OBJ_SCOPE(obj);
|
fun = (JSFunction *) JS_GetPrivate(cx, obj);
|
||||||
for (sprop = SCOPE_LAST_PROP(scope); sprop; sprop = sprop->parent) {
|
do {
|
||||||
if (sprop->setter == setter && (uintN) sprop->shortid == slot) {
|
JS_LOCK_OBJ(cx, obj);
|
||||||
if (sprop->attrs & JSPROP_SHARED) {
|
scope = OBJ_SCOPE(obj);
|
||||||
sprop = js_ChangeNativePropertyAttrs(cx, obj, sprop,
|
for (sprop = SCOPE_LAST_PROP(scope); sprop; sprop = sprop->parent) {
|
||||||
0, ~JSPROP_SHARED,
|
if (sprop->setter == setter && (uintN) sprop->shortid == slot) {
|
||||||
sprop->getter, setter);
|
if (sprop->attrs & JSPROP_SHARED) {
|
||||||
if (!sprop) {
|
if (obj == origobj) {
|
||||||
ok = JS_FALSE;
|
sprop = js_ChangeNativePropertyAttrs(cx, obj, sprop,
|
||||||
} else {
|
0, ~JSPROP_SHARED,
|
||||||
/* See js_SetProperty, near the bottom. */
|
sprop->getter,
|
||||||
GC_POKE(cx, pval);
|
setter);
|
||||||
LOCKED_OBJ_SET_SLOT(obj, sprop->slot, v);
|
if (!sprop) {
|
||||||
|
ok = JS_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See js_SetProperty, near the bottom. */
|
||||||
|
LOCKED_OBJ_SET_SLOT(origobj, sprop->slot, v);
|
||||||
|
} else {
|
||||||
|
ok = js_DefineNativeProperty(cx, origobj, sprop->id, v,
|
||||||
|
sprop->getter,
|
||||||
|
sprop->setter,
|
||||||
|
sprop->attrs &
|
||||||
|
~JSPROP_SHARED,
|
||||||
|
sprop->flags,
|
||||||
|
sprop->shortid, NULL);
|
||||||
|
if (!ok)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
done = JS_TRUE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
JS_UNLOCK_OBJ(cx, obj);
|
||||||
JS_UNLOCK_OBJ(cx, obj);
|
} while (ok && !done && (obj = OBJ_GET_PROTO(cx, obj)) != NULL &&
|
||||||
|
OBJ_GET_CLASS(cx, obj) == &js_FunctionClass &&
|
||||||
|
(JSFunction *) JS_GetPrivate(cx, obj) == fun);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче