Ignore:
Timestamp:
Feb 1, 2012, 4:08:00 PM (13 years ago)
Author:
[email protected]
Message:

calling function on catch block scope containing an eval result in wrong this value being passed
https://bugs.webkit.org/show_bug.cgi?id=77581

Reviewed by Oliver Hunt.

javascript:function F(){ return 'F' in this; }; try { throw F; } catch (e) { eval(""); alert(e()); }

Source/JavaScriptCore:

  • bytecompiler/NodesCodegen.cpp:

(JSC::TryNode::emitBytecode):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::execute):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createTryStatement):

  • parser/NodeConstructors.h:

(JSC::TryNode::TryNode):

  • parser/Nodes.h:

(TryNode):

  • parser/Parser.cpp:

(JSC::::parseTryStatement):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createTryStatement):

  • runtime/JSObject.h:

(JSObject):
(JSC::JSObject::isStaticScopeObject):
(JSC):

LayoutTests:

  • fast/js/eval-var-decl-expected.txt:
  • fast/js/script-tests/eval-var-decl.js:

(checkThis):
(testEvalInCatch):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r106297 r106512  
    604604    TreeStatement tryBlock = 0;
    605605    const Identifier* ident = &m_globalData->propertyNames->nullIdentifier;
    606     bool catchHasEval = false;
    607606    TreeStatement catchBlock = 0;
    608607    TreeStatement finallyBlock = 0;
     
    627626        consumeOrFail(CLOSEPAREN);
    628627        matchOrFail(OPENBRACE);
    629         int initialEvalCount = context.evalCount();
    630628        catchBlock = parseBlockStatement(context);
    631629        failIfFalseWithMessage(catchBlock, "'try' must have a catch or finally block");
    632         catchHasEval = initialEvalCount != context.evalCount();
    633630        failIfFalse(popScope(catchScope, TreeBuilder::NeedsFreeVariableInfo));
    634631    }
     
    641638    }
    642639    failIfFalse(catchBlock || finallyBlock);
    643     return context.createTryStatement(m_lexer->lastLineNumber(), tryBlock, ident, catchHasEval, catchBlock, finallyBlock, firstLine, lastLine);
     640    return context.createTryStatement(m_lexer->lastLineNumber(), tryBlock, ident, catchBlock, finallyBlock, firstLine, lastLine);
    644641}
    645642
Note: See TracChangeset for help on using the changeset viewer.