Ignore:
Timestamp:
May 23, 2008, 4:07:19 PM (17 years ago)
Author:
[email protected]
Message:

2008-05-23 Kevin McCullough <[email protected]>

Reviewed by Sam.

<rdar://problem/5960012> JSProfiler: Stack overflow if recursion is
too deep.
-Use a simple depth limit to restrict too deep of recursion.

  • profiler/Profile.cpp: (KJS::Profile::willExecute): (KJS::Profile::didExecute):
  • profiler/Profile.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/profiler/Profile.cpp

    r34090 r34092  
    3636namespace KJS {
    3737
     38const unsigned DEPTH_LIMIT = 1000;
     39
    3840Profile::Profile(const UString& title, ExecState* originatingGlobalExec, unsigned pageGroupIdentifier)
    3941    : m_title(title)
    4042    , m_originatingGlobalExec(originatingGlobalExec)
    4143    , m_pageGroupIdentifier(pageGroupIdentifier)
     44    , m_depth(0)
    4245{
    4346    // FIXME: When multi-threading is supported this will be a vector and calls
     
    5255    m_originatingGlobalExec = 0;
    5356    m_headNode->stopProfiling();
     57    m_depth = 0;
    5458}
    5559
    5660void Profile::willExecute(const CallIdentifier& callIdentifier)
    5761{
     62    if (++m_depth >= DEPTH_LIMIT)
     63        return;
     64       
    5865    ASSERT(m_currentNode);
    5966    m_currentNode = m_currentNode->willExecute(callIdentifier);
     
    7784
    7885    m_currentNode = m_currentNode->didExecute();
     86    --m_depth;
    7987}
    8088
Note: See TracChangeset for help on using the changeset viewer.