Ignore:
Timestamp:
Dec 23, 2015, 6:17:03 PM (9 years ago)
Author:
[email protected]
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):

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.