Bug 959705. Fix unsafe reference hazards in xpconnect code. r=bholley

This commit is contained in:
Boris Zbarsky 2014-01-14 21:46:44 -05:00
parent f4a5d99834
commit f1a348da85
3 changed files with 7 additions and 6 deletions

View File

@ -1013,8 +1013,8 @@ mozJSComponentLoader::ObjectForLocation(nsIFile *aComponentFile,
if (script) {
ok = JS_ExecuteScriptVersion(cx, obj, script, nullptr, JSVERSION_LATEST);
} else {
jsval rval;
ok = JS_CallFunction(cx, obj, function, 0, nullptr, &rval);
RootedValue rval(cx);
ok = JS_CallFunction(cx, obj, function, 0, nullptr, rval.address());
}
}

View File

@ -3408,8 +3408,8 @@ nsXPCComponents_Utils::GetIncumbentGlobal(const Value &aCallback,
// Invoke the callback, if passed.
if (aCallback.isObject()) {
Value ignored;
if (!JS_CallFunctionValue(aCx, nullptr, aCallback, 1, globalVal.address(), &ignored))
RootedValue ignored(aCx);
if (!JS_CallFunctionValue(aCx, nullptr, aCallback, 1, globalVal.address(), ignored.address()))
return NS_ERROR_FAILURE;
}

View File

@ -1134,14 +1134,15 @@ ProcessArgs(JSContext *cx, JS::Handle<JSObject*> obj, char **argv, int argc, XPC
break;
case 'e':
{
jsval rval;
RootedValue rval(cx);
if (++i == argc) {
return usage();
}
JS_EvaluateScriptForPrincipals(cx, obj, gJSPrincipals, argv[i],
strlen(argv[i]), "-e", 1, &rval);
strlen(argv[i]), "-e", 1,
rval.address());
isInteractive = false;
break;