mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 473709 - Protect |str| across the call to js_NewRegExp. r=jwalden
This commit is contained in:
parent
3b2b3f024d
commit
390a28ac59
@ -936,6 +936,10 @@ class JSAutoTempValueRooter
|
||||
: mContext(cx) {
|
||||
JS_PUSH_SINGLE_TEMP_ROOT(mContext, v, &mTvr);
|
||||
}
|
||||
JSAutoTempValueRooter(JSContext *cx, JSString *str)
|
||||
: mContext(cx) {
|
||||
JS_PUSH_TEMP_ROOT_STRING(mContext, str, &mTvr);
|
||||
}
|
||||
|
||||
~JSAutoTempValueRooter() {
|
||||
JS_POP_TEMP_ROOT(mContext, &mTvr);
|
||||
|
@ -4897,15 +4897,14 @@ js_NewRegExpObject(JSContext *cx, JSTokenStream *ts,
|
||||
JSString *str;
|
||||
JSObject *obj;
|
||||
JSRegExp *re;
|
||||
JSTempValueRooter tvr;
|
||||
|
||||
str = js_NewStringCopyN(cx, chars, length);
|
||||
if (!str)
|
||||
return NULL;
|
||||
JSAutoTempValueRooter tvr(cx, str);
|
||||
re = js_NewRegExp(cx, ts, str, flags, JS_FALSE);
|
||||
if (!re)
|
||||
return NULL;
|
||||
JS_PUSH_TEMP_ROOT_STRING(cx, str, &tvr);
|
||||
obj = js_NewObject(cx, &js_RegExpClass, NULL, NULL, 0);
|
||||
if (!obj || !JS_SetPrivate(cx, obj, re)) {
|
||||
js_DestroyRegExp(cx, re);
|
||||
@ -4913,7 +4912,6 @@ js_NewRegExpObject(JSContext *cx, JSTokenStream *ts,
|
||||
}
|
||||
if (obj && !js_SetLastIndex(cx, obj, 0))
|
||||
obj = NULL;
|
||||
JS_POP_TEMP_ROOT(cx, &tvr);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user