mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 573578: intern string before converting to jsid in PropertyOpForwarder
This commit is contained in:
parent
90a6ed7cd3
commit
4ab1d47307
@ -111,6 +111,22 @@ using namespace js;
|
|||||||
JS_PUBLIC_DATA(jsid) JSID_VOID = { (size_t)JSID_VOID_TYPE };
|
JS_PUBLIC_DATA(jsid) JSID_VOID = { (size_t)JSID_VOID_TYPE };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
JS_FRIEND_API(JSBool)
|
||||||
|
JSVAL_TO_JSID(JSContext *cx, const jsval *vp, jsid *id)
|
||||||
|
{
|
||||||
|
const jsval &v = *vp;
|
||||||
|
if (JSVAL_IS_STRING(v))
|
||||||
|
return js_ValueToStringId(cx, js::Valueify(v), id);
|
||||||
|
|
||||||
|
if (JSVAL_IS_INT(v))
|
||||||
|
*id = INT_TO_JSID(JSVAL_TO_INT(v));
|
||||||
|
else if (JSVAL_IS_VOID(v))
|
||||||
|
*id = JSID_VOID;
|
||||||
|
else
|
||||||
|
*id = OBJECT_TO_JSID(JSVAL_TO_OBJECT(v));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
JS_PUBLIC_API(int64)
|
JS_PUBLIC_API(int64)
|
||||||
JS_Now()
|
JS_Now()
|
||||||
{
|
{
|
||||||
|
@ -413,6 +413,14 @@ JSID_IS_VOID(jsid id)
|
|||||||
return ((size_t)JSID_BITS(id) == JSID_VOID_TYPE);
|
return ((size_t)JSID_BITS(id) == JSID_VOID_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert a JSVAL to a JSID. The input value must be a string, object, or
|
||||||
|
* undefined. The string will be interned if necessary. Return false on
|
||||||
|
* failure, which occurs iff string interning was required and failed.
|
||||||
|
*/
|
||||||
|
JS_FRIEND_API(JSBool)
|
||||||
|
JSVAL_TO_JSID(JSContext *cx, const jsval *vp, jsid *id);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
extern JS_PUBLIC_DATA(jsid) JSID_VOID;
|
extern JS_PUBLIC_DATA(jsid) JSID_VOID;
|
||||||
#else
|
#else
|
||||||
|
@ -119,18 +119,6 @@ LookupInterfaceOrAncestor(PRUint32 tableSize, const xpc_qsHashEntry *table,
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline jsid
|
|
||||||
JSValHoldingJSIdToJSId(jsval v)
|
|
||||||
{
|
|
||||||
if (JSVAL_IS_STRING(v))
|
|
||||||
return INTERNED_STRING_TO_JSID(JSVAL_TO_STRING(v));
|
|
||||||
if (JSVAL_IS_INT(v))
|
|
||||||
return INT_TO_JSID(JSVAL_TO_INT(v));
|
|
||||||
if (JSVAL_IS_VOID(v))
|
|
||||||
return JSID_VOID;
|
|
||||||
return OBJECT_TO_JSID(JSVAL_TO_OBJECT(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
PropertyOpForwarder(JSContext *cx, uintN argc, jsval *vp)
|
PropertyOpForwarder(JSContext *cx, uintN argc, jsval *vp)
|
||||||
{
|
{
|
||||||
@ -152,8 +140,10 @@ PropertyOpForwarder(JSContext *cx, uintN argc, jsval *vp)
|
|||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
jsval argval = (argc > 0) ? JS_ARGV(cx, vp)[0] : JSVAL_VOID;
|
jsval argval = (argc > 0) ? JS_ARGV(cx, vp)[0] : JSVAL_VOID;
|
||||||
|
jsid id;
|
||||||
|
if (!JSVAL_TO_JSID(cx, &argval, &id))
|
||||||
|
return JS_FALSE;
|
||||||
JS_SET_RVAL(cx, vp, argval);
|
JS_SET_RVAL(cx, vp, argval);
|
||||||
jsid id = JSValHoldingJSIdToJSId(argval);
|
|
||||||
return (*popp)(cx, obj, id, vp);
|
return (*popp)(cx, obj, id, vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user