Bug 338804: Making rooting bulletproof. r=mrbkap,sr=brendan

This commit is contained in:
igor%mir2.org 2006-05-23 07:54:17 +00:00
parent 4fe17a2aa1
commit 3df7a16da3
4 changed files with 15 additions and 4 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}