Bug 867459: Rooting fixes for ipc r=terrence

This commit is contained in:
David Zbarsky 2013-05-03 17:49:47 -04:00
parent d02fa60c1c
commit d48e979f76
2 changed files with 14 additions and 15 deletions

View File

@ -92,7 +92,7 @@ TestShellCommandParent::RunCallback(const nsString& aResponse)
JSAutoRequest ar(mCx);
JSObject* global = JS_GetGlobalObject(mCx);
JS::Rooted<JSObject*> global(mCx, JS_GetGlobalObject(mCx));
NS_ENSURE_TRUE(global, JS_FALSE);
JSAutoCompartment ac(mCx, global);

View File

@ -278,9 +278,9 @@ Load(JSContext *cx,
unsigned argc,
JS::Value *vp)
{
JS::Value result;
JS::Rooted<JS::Value> result(cx);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
JS::Rooted<JSObject*> obj(cx, JS_THIS_OBJECT(cx, vp));
if (!obj)
return JS_FALSE;
@ -309,7 +309,7 @@ Load(JSContext *cx,
return JS_FALSE;
if (!Environment(cx)->ShouldCompileOnly() &&
!JS_ExecuteScript(cx, obj, script, &result)) {
!JS_ExecuteScript(cx, obj, script, result.address())) {
return JS_FALSE;
}
}
@ -523,7 +523,7 @@ typedef enum JSShellErrNum
static void
ProcessFile(JSContext *cx,
JSObject *obj,
JS::Handle<JSObject*> obj,
const char *filename,
FILE *file,
JSBool forceTTY)
@ -533,7 +533,7 @@ ProcessFile(JSContext *cx,
pusher.Push(env->GetContext());
JSScript *script;
JS::Value result;
JS::Rooted<JS::Value> result(cx);
int lineno, startline;
JSBool ok, hitEOF;
char *bufp, buffer[4096];
@ -571,10 +571,9 @@ ProcessFile(JSContext *cx,
options.setUTF8(true)
.setFileAndLine(filename, 1)
.setPrincipals(env->GetPrincipal());
JS::RootedObject rootedObj(cx, obj);
JSScript* script = JS::Compile(cx, rootedObj, options, file);
JSScript* script = JS::Compile(cx, obj, options, file);
if (script && !env->ShouldCompileOnly())
(void)JS_ExecuteScript(cx, obj, script, &result);
(void)JS_ExecuteScript(cx, obj, script, result.address());
return;
}
@ -614,7 +613,7 @@ ProcessFile(JSContext *cx,
JSErrorReporter older;
if (!env->ShouldCompileOnly()) {
ok = JS_ExecuteScript(cx, obj, script, &result);
ok = JS_ExecuteScript(cx, obj, script, result.address());
if (ok && result != JSVAL_VOID) {
/* Suppress error reports from JS_ValueToString(). */
older = JS_SetErrorReporter(cx, NULL);
@ -1027,8 +1026,8 @@ XPCShellEnvironment::Init()
return false;
}
JSObject *globalObj;
rv = holder->GetJSObject(&globalObj);
JS::Rooted<JSObject*> globalObj(cx);
rv = holder->GetJSObject(globalObj.address());
if (NS_FAILED(rv)) {
NS_ERROR("Failed to get global JSObject!");
return false;
@ -1072,7 +1071,7 @@ XPCShellEnvironment::EvaluateString(const nsString& aString,
JS_ClearPendingException(mCx);
JSObject* global = GetGlobalObject();
JS::Rooted<JSObject*> global(mCx, GetGlobalObject());
JSAutoCompartment ac(mCx, global);
JSScript* script =
@ -1088,8 +1087,8 @@ XPCShellEnvironment::EvaluateString(const nsString& aString,
aResult->Truncate();
}
JS::Value result;
JSBool ok = JS_ExecuteScript(mCx, global, script, &result);
JS::Rooted<JS::Value> result(mCx);
JSBool ok = JS_ExecuteScript(mCx, global, script, result.address());
if (ok && result != JSVAL_VOID) {
JSErrorReporter old = JS_SetErrorReporter(mCx, NULL);
JSString* str = JS_ValueToString(mCx, result);