Bug 863084 - Fix JS shell evaluate function to use the right Zone for its return value. r=billm

This commit is contained in:
Jan de Mooij 2013-04-20 16:14:24 +02:00
parent 64a3173899
commit d92592f418
2 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,17 @@
// |jit-test| error: too much recursion
function f(code) {
try {
eval(code)
} catch (e) {}
eval(code)
}
f("\
z=evalcx('');\
gc();\
z.toString=(function(){\
v=evaluate(\"(Math.atan2(\\\"\\\",this))\",{\
global:z,newContext:7,catchTermination:this\
});\
});\
String(z)\
")

View File

@ -912,6 +912,7 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
unsigned lineNumber = 1;
RootedObject global(cx, NULL);
bool catchTermination = false;
RootedObject callerGlobal(cx, cx->global());
global = JS_GetGlobalForObject(cx, &args.callee());
if (!global)
@ -1043,6 +1044,7 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp)
}
if (!JS_ExecuteScript(cx, global, script, vp)) {
if (catchTermination && !JS_IsExceptionPending(cx)) {
JSAutoCompartment ac1(cx, callerGlobal);
JSString *str = JS_NewStringCopyZ(cx, "terminated");
if (!str)
return false;