⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 280886 in webkit


Ignore:
Timestamp:
Aug 11, 2021, 12:39:26 AM (5 years ago)
Author:
ysuzuki@apple.com
Message:

WTFCrash in JSC::Lexer<char16_t>::append8
https://bugs.webkit.org/show_bug.cgi?id=228982

Reviewed by Mark Lam.

JSTests:

  • stress/directive-includes-non-latin1.js: Added.

Source/JavaScriptCore:

sourceURL / sourceMapURL directive should not assume Latin1 characters.

  • parser/Lexer.cpp:

(JSC::Lexer<T>::parseCommentDirectiveValue):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r280825 r280886  
     12021-08-11  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        WTFCrash in JSC::Lexer<char16_t>::append8
     4        https://bugs.webkit.org/show_bug.cgi?id=228982
     5
     6        Reviewed by Mark Lam.
     7
     8        * stress/directive-includes-non-latin1.js: Added.
     9
    1102021-08-09  Yusuke Suzuki  <ysuzuki@apple.com>
    211
  • trunk/Source/JavaScriptCore/ChangeLog

    r280858 r280886  
     12021-08-11  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        WTFCrash in JSC::Lexer<char16_t>::append8
     4        https://bugs.webkit.org/show_bug.cgi?id=228982
     5
     6        Reviewed by Mark Lam.
     7
     8        sourceURL / sourceMapURL directive should not assume Latin1 characters.
     9
     10        * parser/Lexer.cpp:
     11        (JSC::Lexer<T>::parseCommentDirectiveValue):
     12
    1132021-08-10  Keith Miller  <keith_miller@apple.com>
    214
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r280825 r280886  
    18431843{
    18441844    skipWhitespace();
     1845    bool hasNonLatin1 = false;
    18451846    const T* stringStart = currentSourcePtr();
    1846     while (!isWhiteSpace(m_current) && !isLineTerminator(m_current) && m_current != '"' && m_current != '\'' && !atEnd())
    1847         shift();
     1847    while (!isWhiteSpace(m_current) && !isLineTerminator(m_current) && m_current != '"' && m_current != '\'' && !atEnd()) {
     1848        if (!isLatin1(m_current))
     1849            hasNonLatin1 = true;
     1850        shift();
     1851    }
    18481852    const T* stringEnd = currentSourcePtr();
    18491853    skipWhitespace();
     
    18521856        return String();
    18531857
    1854     append8(stringStart, stringEnd - stringStart);
    1855     String result = String(m_buffer8.data(), m_buffer8.size());
    1856     m_buffer8.shrink(0);
     1858    unsigned length = stringEnd - stringStart;
     1859    if (hasNonLatin1) {
     1860        UChar* buffer = nullptr;
     1861        String result = StringImpl::createUninitialized(length, buffer);
     1862        StringImpl::copyCharacters(buffer, stringStart, length);
     1863        return result;
     1864    }
     1865
     1866    LChar* buffer = nullptr;
     1867    String result = StringImpl::createUninitialized(length, buffer);
     1868    StringImpl::copyCharacters(buffer, stringStart, length);
    18571869    return result;
    18581870}
Note: See TracChangeset for help on using the changeset viewer.