Bug 55249 - Leak in JSParser::Scope of ScopeLabelInfo Vector
Summary: Leak in JSParser::Scope of ScopeLabelInfo Vector
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All OS X 10.5
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-25 11:32 PST by Michael Saboff
Modified: 2011-02-25 17:27 PST (History)
0 users

See Also:


Attachments
Added Destructor to clean up JSParser::Scope leak of ScopeLabelInfo Vector (1.20 KB, patch)
2011-02-25 11:39 PST, Michael Saboff
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2011-02-25 11:32:16 PST
In the struct Scope, the fuction pushLabel creates a LabelStack as needed that never gets cleaned up.

        void pushLabel(const Identifier* label, bool isLoop)
        {
            if (!m_labels)
                m_labels = new LabelStack;
            m_labels->append(ScopeLabelInfo(label->impl(), isLoop));
        }
Comment 1 Michael Saboff 2011-02-25 11:39:14 PST
Created attachment 83857 [details]
Added Destructor to clean up JSParser::Scope leak of ScopeLabelInfo Vector
Comment 2 Darin Adler 2011-02-25 11:42:19 PST
Comment on attachment 83857 [details]
Added Destructor to clean up JSParser::Scope leak of ScopeLabelInfo Vector

View in context: https://bugs.webkit.org/attachment.cgi?id=83857&action=review

I’d rather see m_labels be changed to an OwnPtr than just add the missing deletion.

> Source/JavaScriptCore/parser/JSParser.cpp:300
> +            if (m_labels)
> +                delete m_labels;

The if isn’t needed. C++ defines the delete operator to do nothing if the pointer passed is null.
Comment 3 Michael Saboff 2011-02-25 17:27:17 PST
Committed r79749: <http://trac.webkit.org/changeset/79749>