Ignore:
Timestamp:
Jun 2, 2008, 9:36:01 AM (17 years ago)
Author:
[email protected]
Message:

2008-06-02 Geoffrey Garen <[email protected]>

Reviewed by Adele Peterson.

Added a specific affordance for avoiding stack overflow when converting
recursive arrays to string, in preparation for removing generic stack
overflow checking from JSObject::call.


Tested by fast/js/toString-stack-overflow.html.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r33979 r34304  
    9393        return throwError(exec, TypeError);
    9494
    95     bool alreadyVisited = !exec->dynamicGlobalObject()->arrayVisitedElements().add(thisObj).second;
     95    HashSet<JSObject*>& arrayVisitedElements = exec->dynamicGlobalObject()->arrayVisitedElements();
     96    if (arrayVisitedElements.size() > MaxReentryDepth)
     97        return throwError(exec, RangeError, "Maximum call stack size exceeded.");
     98
     99    bool alreadyVisited = !arrayVisitedElements.add(thisObj).second;
    96100    Vector<UChar, 256> strBuffer;
    97101    if (alreadyVisited)
     
    132136        return throwError(exec, TypeError);
    133137
    134     bool alreadyVisited = !exec->dynamicGlobalObject()->arrayVisitedElements().add(thisObj).second;
     138    HashSet<JSObject*>& arrayVisitedElements = exec->dynamicGlobalObject()->arrayVisitedElements();
     139    if (arrayVisitedElements.size() > MaxReentryDepth)
     140        return throwError(exec, RangeError, "Maximum call stack size exceeded.");
     141
     142    bool alreadyVisited = !arrayVisitedElements.add(thisObj).second;
    135143    Vector<UChar, 256> strBuffer;
    136144    if (alreadyVisited)
     
    174182JSValue* arrayProtoFuncJoin(ExecState* exec, JSObject* thisObj, const List& args)
    175183{
    176     bool alreadyVisited = !exec->dynamicGlobalObject()->arrayVisitedElements().add(thisObj).second;
     184    HashSet<JSObject*>& arrayVisitedElements = exec->dynamicGlobalObject()->arrayVisitedElements();
     185    if (arrayVisitedElements.size() > MaxReentryDepth)
     186        return throwError(exec, RangeError, "Maximum call stack size exceeded.");
     187
     188    bool alreadyVisited = !arrayVisitedElements.add(thisObj).second;
    177189    Vector<UChar, 256> strBuffer;
    178190    if (alreadyVisited)
Note: See TracChangeset for help on using the changeset viewer.