Changeset 239227 in webkit


Ignore:
Timestamp:
Dec 14, 2018 12:53:08 PM (5 years ago)
Author:
keith_miller@apple.com
Message:

Callers of JSString::getIndex should check for OOM exceptions
https://bugs.webkit.org/show_bug.cgi?id=192709

Reviewed by Mark Lam.

JSTests:

  • stress/StringObject-define-length-getter-rope-string-oom.js: Added.

Source/JavaScriptCore:

This patch also allows Strings to OOM when the StringObject wrapper
attempts to look up an own property on the string.

Remove isExtensibleImpl because it's only used in one place and call
isStructureExtensible instead.

  • runtime/JSObject.cpp:

(JSC::JSObject::isExtensible):

  • runtime/JSObject.h:

(JSC::JSObject::isExtensibleImpl): Deleted.

  • runtime/JSString.h:

(JSC::JSString::getStringPropertySlot):

  • runtime/StringObject.cpp:

(JSC::StringObject::defineOwnProperty):

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r239198 r239227  
     12018-12-14  Keith Miller  <keith_miller@apple.com>
     2
     3        Callers of JSString::getIndex should check for OOM exceptions
     4        https://bugs.webkit.org/show_bug.cgi?id=192709
     5
     6        Reviewed by Mark Lam.
     7
     8        * stress/StringObject-define-length-getter-rope-string-oom.js: Added.
     9
    1102018-12-13  Mark Lam  <mark.lam@apple.com>
    211
  • trunk/Source/JavaScriptCore/ChangeLog

    r239200 r239227  
     12018-12-14  Keith Miller  <keith_miller@apple.com>
     2
     3        Callers of JSString::getIndex should check for OOM exceptions
     4        https://bugs.webkit.org/show_bug.cgi?id=192709
     5
     6        Reviewed by Mark Lam.
     7
     8        This patch also allows Strings to OOM when the StringObject wrapper
     9        attempts to look up an own property on the string.
     10
     11        Remove isExtensibleImpl because it's only used in one place and call
     12        isStructureExtensible instead.
     13
     14        * runtime/JSObject.cpp:
     15        (JSC::JSObject::isExtensible):
     16        * runtime/JSObject.h:
     17        (JSC::JSObject::isExtensibleImpl): Deleted.
     18        * runtime/JSString.h:
     19        (JSC::JSString::getStringPropertySlot):
     20        * runtime/StringObject.cpp:
     21        (JSC::StringObject::defineOwnProperty):
     22
    1232018-12-13  Fujii Hironori  <Hironori.Fujii@sony.com>
    224
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r239062 r239227  
    24322432bool JSObject::isExtensible(JSObject* obj, ExecState* exec)
    24332433{
    2434     return obj->isExtensibleImpl(exec->vm());
     2434    return obj->isStructureExtensible(exec->vm());
    24352435}
    24362436
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r239062 r239227  
    754754private:
    755755    NonPropertyTransition suggestedArrayStorageTransition(VM&) const;
    756     ALWAYS_INLINE bool isExtensibleImpl(VM& vm) { return isStructureExtensible(vm); }
    757756public:
    758757    // You should only call isStructureExtensible() when:
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r236804 r239227  
    688688{
    689689    VM& vm = exec->vm();
     690    auto scope = DECLARE_THROW_SCOPE(vm);
     691
    690692    if (propertyName == vm.propertyNames->length) {
    691693        slot.setValue(this, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly, jsNumber(length()));
     
    695697    std::optional<uint32_t> index = parseIndex(propertyName);
    696698    if (index && index.value() < length()) {
    697         slot.setValue(this, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly, getIndex(exec, index.value()));
     699        JSValue value = getIndex(exec, index.value());
     700        RETURN_IF_EXCEPTION(scope, false);
     701        slot.setValue(this, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly, value);
    698702        return true;
    699703    }
     
    704708ALWAYS_INLINE bool JSString::getStringPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
    705709{
     710    VM& vm = exec->vm();
     711    auto scope = DECLARE_THROW_SCOPE(vm);
     712
    706713    if (propertyName < length()) {
    707         slot.setValue(this, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly, getIndex(exec, propertyName));
     714        JSValue value = getIndex(exec, propertyName);
     715        RETURN_IF_EXCEPTION(scope, false);
     716        slot.setValue(this, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly, value);
    708717        return true;
    709718    }
  • trunk/Source/JavaScriptCore/runtime/StringObject.cpp

    r236697 r239227  
    115115        PropertyDescriptor current;
    116116        bool isCurrentDefined = thisObject->getOwnPropertyDescriptor(exec, propertyName, current);
    117         ASSERT(isCurrentDefined);
     117        EXCEPTION_ASSERT(!scope.exception() == isCurrentDefined);
     118        RETURN_IF_EXCEPTION(scope, false);
    118119        bool isExtensible = thisObject->isExtensible(exec);
    119120        RETURN_IF_EXCEPTION(scope, false);
Note: See TracChangeset for help on using the changeset viewer.