Bug 473075 - TM: HasProperty can call into exotic lookupProperty hooks. r=brendan.

This commit is contained in:
Jason Orendorff
2009-02-05 19:49:54 -06:00
parent f2bee02542
commit 579f3a7501
2 changed files with 13 additions and 5 deletions

View File

@@ -328,16 +328,17 @@ js_AddProperty(JSContext* cx, JSObject* obj, JSScopeProperty* sprop)
static JSBool
HasProperty(JSContext* cx, JSObject* obj, jsid id)
{
// check whether we know how the resolve op will behave
// Check that we know how the lookup op will behave.
if (obj->map->ops->lookupProperty != js_LookupProperty)
return JSVAL_TO_PSEUDO_BOOLEAN(JSVAL_VOID);
JSClass* clasp = OBJ_GET_CLASS(cx, obj);
if (clasp->resolve != JS_ResolveStub && clasp != &js_StringClass)
return JSVAL_TO_BOOLEAN(JSVAL_VOID);
return JSVAL_TO_PSEUDO_BOOLEAN(JSVAL_VOID);
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
JSObject* obj2;
JSProperty* prop;
if (!OBJ_LOOKUP_PROPERTY(cx, obj, id, &obj2, &prop))
return JSVAL_TO_BOOLEAN(JSVAL_VOID);
if (!js_LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop))
return JSVAL_TO_PSEUDO_BOOLEAN(JSVAL_VOID);
if (prop)
OBJ_DROP_PROPERTY(cx, obj2, prop);
return prop != NULL;