Fix recently-uncovered ECMA violation: lastIndex must use double storage (124339, r=rogerl, sr=shaver).
git-svn-id: svn://10.0.0.236/trunk@114095 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
27aa25dce9
commit
e6452400a0
@ -1227,10 +1227,10 @@ js_NewRegExp(JSContext *cx, JSTokenStream *ts,
|
||||
if (!re)
|
||||
goto out;
|
||||
re->nrefs = 1;
|
||||
re->source = str;
|
||||
re->lastIndex = 0;
|
||||
re->parenCount = state.parenCount;
|
||||
re->flags = flags;
|
||||
re->lastIndex = 0;
|
||||
re->source = str;
|
||||
#ifdef JS_THREADSAFE
|
||||
re->owningThread = 0;
|
||||
re->lastIndexes = NULL;
|
||||
@ -1247,14 +1247,14 @@ out:
|
||||
typedef struct LastIndexEntry {
|
||||
JSDHashEntryHdr hdr;
|
||||
jsword thread;
|
||||
uintN index;
|
||||
double index;
|
||||
} LastIndexEntry;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NB: Get and SetLastIndex must be called with re's owning object locked.
|
||||
*/
|
||||
static uintN
|
||||
static double
|
||||
GetLastIndex(JSContext *cx, JSRegExp *re)
|
||||
{
|
||||
#ifdef JS_THREADSAFE
|
||||
@ -1279,7 +1279,7 @@ GetLastIndex(JSContext *cx, JSRegExp *re)
|
||||
}
|
||||
|
||||
static JSBool
|
||||
SetLastIndex(JSContext *cx, JSRegExp *re, uintN lastIndex)
|
||||
SetLastIndex(JSContext *cx, JSRegExp *re, double lastIndex)
|
||||
{
|
||||
#ifdef JS_THREADSAFE
|
||||
if (!re->owningThread) {
|
||||
@ -2440,7 +2440,7 @@ regexp_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
JS_LOCK_OBJ(cx, obj);
|
||||
re = (JSRegExp *) JS_GetInstancePrivate(cx, obj, &js_RegExpClass, NULL);
|
||||
if (re)
|
||||
ok = SetLastIndex(cx, re, (uintN)d);
|
||||
ok = SetLastIndex(cx, re, d);
|
||||
JS_UNLOCK_OBJ(cx, obj);
|
||||
}
|
||||
return ok;
|
||||
|
||||
@ -73,14 +73,14 @@ typedef struct RENode RENode;
|
||||
|
||||
struct JSRegExp {
|
||||
jsrefcount nrefs; /* reference count */
|
||||
JSString *source; /* locked source string, sans // */
|
||||
uintN lastIndex; /* number of parenthesized submatches */
|
||||
uint32 parenCount:24, /* index after last match, for //g iterator */
|
||||
uint32 parenCount:24, /* number of parenthesized submatches */
|
||||
flags:8; /* flags, see jsapi.h's JSREG_* defines */
|
||||
double lastIndex; /* index after last match, for //g iterator */
|
||||
RENode *ren; /* regular expression tree root */
|
||||
#ifdef JS_THREADSAFE
|
||||
jsword owningThread; /* not quite right if someone intentionally */
|
||||
JSDHashTable *lastIndexes; /* passes a regexp from thread A to B */
|
||||
JSString *source; /* locked source string, sans // */
|
||||
#ifdef JS_THREADSAFE /* extension: lastIndex is thread-specific */
|
||||
jsword owningThread; /* (not quite right if someone intentionally */
|
||||
JSDHashTable *lastIndexes; /* passes a regexp from thread A to B) */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user