Changeset 264379 in webkit


Ignore:
Timestamp:
Jul 14, 2020, 3:51:19 PM (5 years ago)
Author:
mark.lam@apple.com
Message:

Handle out of memory error while creating an error message in the literal parser.
https://bugs.webkit.org/show_bug.cgi?id=214313
<rdar://problem/65031745>

Reviewed by Saam Barati.

JSTests:

  • stress/out-of-memory-making-error-string-in-literal-parser.js: Added.

Source/JavaScriptCore:

  • runtime/LiteralParser.cpp:

(JSC::LiteralParser<CharType>::parse):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r264336 r264379  
     12020-07-14  Mark Lam  <mark.lam@apple.com>
     2
     3        Handle out of memory error while creating an error message in the literal parser.
     4        https://bugs.webkit.org/show_bug.cgi?id=214313
     5        <rdar://problem/65031745>
     6
     7        Reviewed by Saam Barati.
     8
     9        * stress/out-of-memory-making-error-string-in-literal-parser.js: Added.
     10
    1112020-07-14  Angelos Oikonomopoulos  <angelos@igalia.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r264369 r264379  
     12020-07-14  Mark Lam  <mark.lam@apple.com>
     2
     3        Handle out of memory error while creating an error message in the literal parser.
     4        https://bugs.webkit.org/show_bug.cgi?id=214313
     5        <rdar://problem/65031745>
     6
     7        Reviewed by Saam Barati.
     8
     9        * runtime/LiteralParser.cpp:
     10        (JSC::LiteralParser<CharType>::parse):
     11
    1122020-07-14  Caitlin Potter  <caitp@igalia.com>
    213
  • trunk/Source/JavaScriptCore/runtime/LiteralParser.cpp

    r261895 r264379  
    994994                    case TokIdentifier: {
    995995                        typename Lexer::LiteralParserTokenPtr token = m_lexer.currentToken();
    996                         if (token->stringIs8Bit)
    997                             m_parseErrorMessage = makeString("Unexpected identifier \"", StringView { token->stringToken8, token->stringLength }, '"');
    998                         else
    999                             m_parseErrorMessage = makeString("Unexpected identifier \"", StringView { token->stringToken16, token->stringLength }, '"');
     996
     997                        auto tryMakeErrorString = [=] (typename Lexer::LiteralParserTokenPtr token, unsigned length, bool addEllipsis) -> String {
     998                            if (token->stringIs8Bit)
     999                                return tryMakeString("Unexpected identifier \"", StringView { token->stringToken8, length }, addEllipsis ? "..." : "", '"');
     1000                            return tryMakeString("Unexpected identifier \"", StringView { token->stringToken16, length }, addEllipsis ? "..." : "", '"');
     1001                        };
     1002
     1003                        String errorString = tryMakeErrorString(token, token->stringLength, false);
     1004                        if (!errorString) {
     1005                            constexpr unsigned shortLength = 10;
     1006                            if (token->stringLength > shortLength)
     1007                                errorString = tryMakeErrorString(token, shortLength, true);
     1008                            if (!errorString)
     1009                                errorString = "Unexpected identifier";
     1010                        }
     1011
     1012                        m_parseErrorMessage = errorString;
    10001013                        return JSValue();
    10011014                    }
Note: See TracChangeset for help on using the changeset viewer.