From d18abf02e1b5832839ccb00a0c13d58381c6fcf9 Mon Sep 17 00:00:00 2001 From: "igor%mir2.org" Date: Sun, 17 Mar 2002 20:10:31 +0000 Subject: [PATCH] Code to setup/restore security domain is moved to single place in Interpreter.interpret to make checking for correctness easy. git-svn-id: svn://10.0.0.236/trunk@116753 18797224-902f-48f8-a5cc-f745e15eee43 --- .../org/mozilla/javascript/Interpreter.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mozilla/js/rhino/src/org/mozilla/javascript/Interpreter.java b/mozilla/js/rhino/src/org/mozilla/javascript/Interpreter.java index abd049ffe86..b458128d27f 100644 --- a/mozilla/js/rhino/src/org/mozilla/javascript/Interpreter.java +++ b/mozilla/js/rhino/src/org/mozilla/javascript/Interpreter.java @@ -1403,6 +1403,18 @@ public class Interpreter extends LabelTable { InterpreterData theData) throws JavaScriptException { + if (cx.interpreterSecurityDomain != theData.securityDomain) { + // If securityDomain is different, update domain in Cotext + // and call self under new domain + Object savedDomain = cx.interpreterSecurityDomain; + cx.interpreterSecurityDomain = theData.securityDomain; + try { + return interpret(cx, scope, thisObj, args, fnOrScript, theData); + } finally { + cx.interpreterSecurityDomain = savedDomain; + } + } + int i; Object lhs; @@ -1480,13 +1492,6 @@ public class Interpreter extends LabelTable { cx.pushFrame(frame); } - /* Save the security domain. Must restore upon normal exit. - * If we exit the interpreter loop by throwing an exception, - * set cx.interpreterSecurityDomain to null, and require the - * catching function to restore it. - */ - Object savedSecurityDomain = cx.interpreterSecurityDomain; - cx.interpreterSecurityDomain = theData.securityDomain; Object result = undefined; int pcPrevBranch = pc; @@ -2212,8 +2217,6 @@ public class Interpreter extends LabelTable { pc++; } catch (Throwable ex) { - cx.interpreterSecurityDomain = null; - if (instructionThreshold != 0) { if (instructionCount < 0) { // throw during function call @@ -2315,10 +2318,8 @@ public class Interpreter extends LabelTable { scope = (Scriptable)stack[TRY_SCOPE_SHFT + tryStackTop]; stackTop = 0; stack[0] = errObj; - cx.interpreterSecurityDomain = theData.securityDomain; } } - cx.interpreterSecurityDomain = savedSecurityDomain; if (frame != null) cx.popFrame();