Ignore:
Timestamp:
Mar 28, 2018, 2:36:44 AM (7 years ago)
Author:
[email protected]
Message:

appendQuotedJSONString stops on arithmetic overflow instead of propagating it upwards
https://bugs.webkit.org/show_bug.cgi?id=183894

Reviewed by Saam Barati.

JSTests:

  • stress/json-stringified-overflow.js: Added.

(catch):

Source/JavaScriptCore:

Use the return value of appendQuotedJSONString to fail more gracefully when given a string that is too large to handle.

  • runtime/JSONObject.cpp:

(JSC::Stringifier::appendStringifiedValue):

Source/WTF:

appendQuotedJSONString now returns a bool indicating whether it succeeded, instead of silently failing when given a string too large
to fit in 4GB.

  • wtf/text/StringBuilder.h:
  • wtf/text/StringBuilderJSON.cpp:

(WTF::StringBuilder::appendQuotedJSONString):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r229410 r230026  
    358358        const String& string = asString(value)->value(m_exec);
    359359        RETURN_IF_EXCEPTION(scope, StringifyFailed);
    360         builder.appendQuotedJSONString(string);
    361         return StringifySucceeded;
     360        if (builder.appendQuotedJSONString(string))
     361            return StringifySucceeded;
     362        throwOutOfMemoryError(m_exec, scope);
     363        return StringifyFailed;
    362364    }
    363365
Note: See TracChangeset for help on using the changeset viewer.