mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 338804: Making rooting bulletproof. r=mrbkap,sr=brendan
This commit is contained in:
parent
4fe17a2aa1
commit
3df7a16da3
@ -529,7 +529,6 @@ static JSBool
|
||||
Exception(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
JSBool ok;
|
||||
jsval pval;
|
||||
uint32 lineno;
|
||||
JSString *message, *filename;
|
||||
JSStackFrame *fp;
|
||||
@ -549,10 +548,10 @@ Exception(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
ok = OBJ_GET_PROPERTY(cx, JSVAL_TO_OBJECT(argv[-2]),
|
||||
ATOM_TO_JSID(cx->runtime->atomState
|
||||
.classPrototypeAtom),
|
||||
&pval);
|
||||
rval);
|
||||
if (!ok)
|
||||
goto out;
|
||||
obj = js_NewObject(cx, &js_ErrorClass, JSVAL_TO_OBJECT(pval), NULL);
|
||||
obj = js_NewObject(cx, &js_ErrorClass, JSVAL_TO_OBJECT(*rval), NULL);
|
||||
if (!obj) {
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
|
@ -2172,6 +2172,7 @@ file_constructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
obj = JS_NewObject(cx, &file_class, NULL, NULL);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
*rval = OBJECT_TO_JSVAL(obj);
|
||||
}
|
||||
|
||||
str = (argc == 0)
|
||||
@ -2191,7 +2192,6 @@ file_constructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
|
||||
SECURITY_CHECK(cx, NULL, "constructor", file);
|
||||
|
||||
*rval = OBJECT_TO_JSVAL(obj);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -4059,6 +4059,12 @@ RegExp(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
obj = js_NewObject(cx, &js_RegExpClass, NULL, NULL);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
|
||||
/*
|
||||
* regexp_compile does not use rval to root its temporaries
|
||||
* so we can use it to root obj.
|
||||
*/
|
||||
*rval = OBJECT_TO_JSVAL(obj);
|
||||
}
|
||||
return regexp_compile(cx, obj, argc, argv, rval);
|
||||
}
|
||||
|
@ -878,6 +878,12 @@ Script(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
obj = js_NewObject(cx, &js_ScriptClass, NULL, NULL);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
|
||||
/*
|
||||
* script_compile does not use rval to root its temporaries
|
||||
* so we can use it to root obj.
|
||||
*/
|
||||
*rval = OBJECT_TO_JSVAL(obj);
|
||||
}
|
||||
return script_compile(cx, obj, argc, argv, rval);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user