Changeset 96438 in webkit


Ignore:
Timestamp:
Sep 30, 2011 4:54:44 PM (13 years ago)
Author:
barraclough@apple.com
Message:

StringRecursionChecker should not work in terms of EncodedJSValue
https://bugs.webkit.org/show_bug.cgi?id=69188

Reviewed by Oliver Hunt.

0 is not the empty value on 32_64.
Code that casts literals to EncodedJSValues may be unsafe if we change our internal representation.

  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncToString):
(JSC::arrayProtoFuncToLocaleString):
(JSC::arrayProtoFuncJoin):

  • runtime/ErrorPrototype.cpp:

(JSC::errorProtoFuncToString):

  • runtime/RegExpPrototype.cpp:

(JSC::regExpProtoFuncToString):

  • runtime/StringRecursionChecker.cpp:

(JSC::StringRecursionChecker::throwStackOverflowError):
(JSC::StringRecursionChecker::emptyString):

  • runtime/StringRecursionChecker.h:

(JSC::StringRecursionChecker::performCheck):
(JSC::StringRecursionChecker::earlyReturnValue):

Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r96436 r96438  
     12011-09-30  Gavin Barraclough  <barraclough@apple.com>
     2
     3        StringRecursionChecker should not work in terms of EncodedJSValue
     4        https://bugs.webkit.org/show_bug.cgi?id=69188
     5
     6        Reviewed by Oliver Hunt.
     7
     8        0 is not the empty value on 32_64.
     9        Code that casts literals to EncodedJSValues may be unsafe if we change our internal representation.
     10
     11        * runtime/ArrayPrototype.cpp:
     12        (JSC::arrayProtoFuncToString):
     13        (JSC::arrayProtoFuncToLocaleString):
     14        (JSC::arrayProtoFuncJoin):
     15        * runtime/ErrorPrototype.cpp:
     16        (JSC::errorProtoFuncToString):
     17        * runtime/RegExpPrototype.cpp:
     18        (JSC::regExpProtoFuncToString):
     19        * runtime/StringRecursionChecker.cpp:
     20        (JSC::StringRecursionChecker::throwStackOverflowError):
     21        (JSC::StringRecursionChecker::emptyString):
     22        * runtime/StringRecursionChecker.h:
     23        (JSC::StringRecursionChecker::performCheck):
     24        (JSC::StringRecursionChecker::earlyReturnValue):
     25
    1262011-09-30  Gavin Barraclough  <barraclough@apple.com>
    227
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r96243 r96438  
    181181
    182182    StringRecursionChecker checker(exec, thisObj);
    183     if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue())
    184         return earlyReturnValue;
     183    if (JSValue earlyReturnValue = checker.earlyReturnValue())
     184        return JSValue::encode(earlyReturnValue);
    185185
    186186    unsigned totalSize = length ? length - 1 : 0;
     
    244244
    245245    StringRecursionChecker checker(exec, thisObj);
    246     if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue())
    247         return earlyReturnValue;
     246    if (JSValue earlyReturnValue = checker.earlyReturnValue())
     247        return JSValue::encode(earlyReturnValue);
    248248
    249249    JSStringBuilder strBuffer;
     
    278278
    279279    StringRecursionChecker checker(exec, thisObj);
    280     if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue())
    281         return earlyReturnValue;
     280    if (JSValue earlyReturnValue = checker.earlyReturnValue())
     281        return JSValue::encode(earlyReturnValue);
    282282
    283283    JSStringBuilder strBuffer;
  • trunk/Source/JavaScriptCore/runtime/ErrorPrototype.cpp

    r95936 r96438  
    8080
    8181    StringRecursionChecker checker(exec, thisObj);
    82     if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue())
    83         return earlyReturnValue;
     82    if (JSValue earlyReturnValue = checker.earlyReturnValue())
     83        return JSValue::encode(earlyReturnValue);
    8484
    8585    JSValue name = thisObj->get(exec, exec->propertyNames().name);
  • trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp

    r95936 r96438  
    143143
    144144    StringRecursionChecker checker(exec, thisObject);
    145     if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue())
    146         return earlyReturnValue;
     145    if (JSValue earlyReturnValue = checker.earlyReturnValue())
     146        return JSValue::encode(earlyReturnValue);
    147147
    148148    char postfix[5] = { '/', 0, 0, 0, 0 };
  • trunk/Source/JavaScriptCore/runtime/StringRecursionChecker.cpp

    r76185 r96438  
    2626namespace JSC {
    2727
    28 EncodedJSValue StringRecursionChecker::throwStackOverflowError()
     28JSValue StringRecursionChecker::throwStackOverflowError()
    2929{
    30     return throwVMError(m_exec, createStackOverflowError(m_exec));
     30    return throwError(m_exec, createStackOverflowError(m_exec));
    3131}
    3232
    33 EncodedJSValue StringRecursionChecker::emptyString()
     33JSValue StringRecursionChecker::emptyString()
    3434{
    35     return JSValue::encode(jsEmptyString(m_exec));
     35    return jsEmptyString(m_exec);
    3636}
    3737
  • trunk/Source/JavaScriptCore/runtime/StringRecursionChecker.h

    r76185 r96438  
    3232    ~StringRecursionChecker();
    3333
    34     EncodedJSValue earlyReturnValue() const; // 0 if everything is OK, value to return for failure cases
     34    JSValue earlyReturnValue() const; // 0 if everything is OK, value to return for failure cases
    3535
    3636private:
    37     EncodedJSValue throwStackOverflowError();
    38     EncodedJSValue emptyString();
    39     EncodedJSValue performCheck();
     37    JSValue throwStackOverflowError();
     38    JSValue emptyString();
     39    JSValue performCheck();
    4040
    4141    ExecState* m_exec;
    4242    JSObject* m_thisObject;
    43     EncodedJSValue m_earlyReturnValue;
     43    JSValue m_earlyReturnValue;
    4444};
    4545
    46 inline EncodedJSValue StringRecursionChecker::performCheck()
     46inline JSValue StringRecursionChecker::performCheck()
    4747{
    4848    int size = m_exec->globalData().stringRecursionCheckVisitedObjects.size();
     
    5252    if (alreadyVisited)
    5353        return emptyString(); // Return empty string to avoid infinite recursion.
    54     return 0; // Indicate success.
     54    return JSValue(); // Indicate success.
    5555}
    5656
     
    6262}
    6363
    64 inline EncodedJSValue StringRecursionChecker::earlyReturnValue() const
     64inline JSValue StringRecursionChecker::earlyReturnValue() const
    6565{
    6666    return m_earlyReturnValue;
Note: See TracChangeset for help on using the changeset viewer.