Changeset 27831 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Nov 15, 2007, 4:40:24 PM (18 years ago)
Author:
[email protected]
Message:

<rdar://problem/5601548> REGRESSION: All SourceElements and their children leak after a syntax error

Reviewed by Darin.

Add a stub node to maintain the Vector of SourceElements until assignment.

Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r27830 r27831  
     12007-11-15  Oliver Hunt  <[email protected]>
     2
     3        Reviewed by Darin.
     4
     5        <rdar://problem/5601548> REGRESSION: All SourceElements and their children leak after a syntax error
     6       
     7        Add a stub node to maintain the Vector of SourceElements until assignment.
     8
     9        * kjs/grammar.y:
     10        * kjs/nodes.h:
     11        (KJS::SourceElementsStub::SourceElementsStub):
     12        (KJS::SourceElementsStub::append):
     13        (KJS::SourceElementsStub::release):
     14        (KJS::SourceElementsStub::):
     15        (KJS::SourceElementsStub::precedence):
     16
    1172007-11-15  Eric Seidel  <[email protected]>
    218
  • trunk/JavaScriptCore/kjs/grammar.y

    r27799 r27831  
    108108    ProgramNode*        programNode;
    109109
    110     SourceElements*    sourceElements;
     110    SourceElementsStub* sourceElements;
    111111    PropertyList        propertyList;
    112112    ArgumentList        argumentList;
     
    661661Block:
    662662    '{' '}'                             { $$ = new BlockNode(new SourceElements); DBG($$, @1, @2); }
    663   | '{' SourceElements '}'              { $$ = new BlockNode($2); DBG($$, @1, @3); }
     663  | '{' SourceElements '}'              { $$ = new BlockNode($2->release()); DBG($$, @1, @3); }
    664664;
    665665
     
    822822CaseClause:
    823823    CASE Expr ':'                       { $$ = new CaseClauseNode($2); }
    824   | CASE Expr ':' SourceElements        { $$ = new CaseClauseNode($2, $4); }
     824  | CASE Expr ':' SourceElements        { $$ = new CaseClauseNode($2, $4->release()); }
    825825;
    826826
    827827DefaultClause:
    828828    DEFAULT ':'                         { $$ = new CaseClauseNode(0); }
    829   | DEFAULT ':' SourceElements          { $$ = new CaseClauseNode(0, $3); }
     829  | DEFAULT ':' SourceElements          { $$ = new CaseClauseNode(0, $3->release()); }
    830830;
    831831
     
    873873FunctionBody:
    874874    /* not in spec */           { $$ = new FunctionBodyNode(new SourceElements); }
    875   | SourceElements              { $$ = new FunctionBodyNode($1); }
     875  | SourceElements              { $$ = new FunctionBodyNode($1->release()); }
    876876;
    877877
    878878Program:
    879879    /* not in spec */                   { Parser::accept(new ProgramNode(new SourceElements)); }
    880     | SourceElements                    { Parser::accept(new ProgramNode($1)); }
     880    | SourceElements                    { Parser::accept(new ProgramNode($1->release())); }
    881881;
    882882
    883883SourceElements:
    884     SourceElement                       { $$ = new SourceElements; $$->append($1); }
     884    SourceElement                       { $$ = new SourceElementsStub; $$->append($1); }
    885885  | SourceElements SourceElement        { $$->append($2); }
    886886;
  • trunk/JavaScriptCore/kjs/nodes.h

    r27749 r27831  
    17291729  typedef Vector<RefPtr<StatementNode> > SourceElements;
    17301730
     1731  class SourceElementsStub : public Node {
     1732  public:
     1733    SourceElementsStub()
     1734      : m_sourceElements(new SourceElements)
     1735      {}
     1736    void append(StatementNode* element) { m_sourceElements->append(element); }
     1737    SourceElements* release() {
     1738        SourceElements* elems = m_sourceElements.release();
     1739        return elems;
     1740    }
     1741    virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL { ASSERT_NOT_REACHED(); }
     1742    virtual Completion execute(ExecState*) KJS_FAST_CALL  { ASSERT_NOT_REACHED(); return Completion(); }
     1743    virtual void streamTo(SourceStream&) const KJS_FAST_CALL  { ASSERT_NOT_REACHED(); }
     1744    virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL  { ASSERT_NOT_REACHED(); }
     1745    virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
     1746  private:
     1747    OwnPtr<SourceElements> m_sourceElements;
     1748  };
     1749   
    17311750  class BlockNode : public StatementNode {
    17321751  public:
Note: See TracChangeset for help on using the changeset viewer.