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

Changeset 194409 in webkit


Ignore:
Timestamp:
Dec 23, 2015, 6:17:03 PM (11 years ago)
Author:
akling@apple.com
Message:

jsc CLI tool crashes on EOF.
<https://webkit.org/b/152522>

Reviewed by Benjamin Poulain.

SourceProvider should treat String() like the empty string for hashing purposes.
This was a subtle behavior change in r194017 due to how zero-length strings are
treated by StringImpl::createSubstringSharingImpl().

I made these SourceProviders store a Ref<StringImpl> internally instead of a
String, to codify the fact that these strings can't be null strings.

I couldn't find a way to cause this crash through the API.

  • API/JSScriptRef.cpp:

(OpaqueJSScript::OpaqueJSScript):

  • parser/SourceProvider.h:

(JSC::StringSourceProvider::StringSourceProvider):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSScriptRef.cpp

    r194017 r194409  
    4949    unsigned hash() const override
    5050    {
    51         return m_source.impl()->hash();
     51        return m_source.get().hash();
    5252    }
    5353
    5454    StringView source() const override
    5555    {
    56         return m_source;
     56        return m_source.get();
    5757    }
    5858
     
    6363        : SourceProvider(url, TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()))
    6464        , m_vm(vm)
    65         , m_source(source)
     65        , m_source(source.isNull() ? *StringImpl::empty() : *source.impl())
    6666    {
    6767    }
     
    7070
    7171    VM* m_vm;
    72     String m_source;
     72    Ref<StringImpl> m_source;
    7373};
    7474
  • trunk/Source/JavaScriptCore/ChangeLog

    r194402 r194409  
     12015-12-23  Andreas Kling  <akling@apple.com>
     2
     3        jsc CLI tool crashes on EOF.
     4        <https://webkit.org/b/152522>
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        SourceProvider should treat String() like the empty string for hashing purposes.
     9        This was a subtle behavior change in r194017 due to how zero-length strings are
     10        treated by StringImpl::createSubstringSharingImpl().
     11
     12        I made these SourceProviders store a Ref<StringImpl> internally instead of a
     13        String, to codify the fact that these strings can't be null strings.
     14
     15        I couldn't find a way to cause this crash through the API.
     16
     17        * API/JSScriptRef.cpp:
     18        (OpaqueJSScript::OpaqueJSScript):
     19        * parser/SourceProvider.h:
     20        (JSC::StringSourceProvider::StringSourceProvider):
     21
    1222015-12-23  Filip Pizlo  <fpizlo@apple.com>
    223
  • trunk/Source/JavaScriptCore/parser/SourceProvider.h

    r194017 r194409  
    9191        unsigned hash() const override
    9292        {
    93             return m_source.impl()->hash();
     93            return m_source.get().hash();
    9494        }
    9595
    9696        virtual StringView source() const override
    9797        {
    98             return m_source;
     98            return m_source.get();
    9999        }
    100100
     
    102102        StringSourceProvider(const String& source, const String& url, const TextPosition& startPosition)
    103103            : SourceProvider(url, startPosition)
    104             , m_source(source)
     104            , m_source(source.isNull() ? *StringImpl::empty() : *source.impl())
    105105        {
    106106        }
    107107
    108         String m_source;
     108        Ref<StringImpl> m_source;
    109109    };
    110110   
Note: See TracChangeset for help on using the changeset viewer.