Ignore:
Timestamp:
Jan 6, 2017, 3:30:57 PM (8 years ago)
Author:
[email protected]
Message:

@putByValDirect in Array.of and Array.from overwrites non-writable/configurable properties
https://bugs.webkit.org/show_bug.cgi?id=153486

Reviewed by Saam Barati.

JSTests:

New regression test.

  • stress/regress-153486.js: Added.

(shouldEqual):
(makeUnwriteableUnconfigurableObject):
(testArrayOf):
(testArrayFrom):
(runTest):

Source/JavaScriptCore:

Moved read only check in putDirect() to all paths.

  • runtime/SparseArrayValueMap.cpp:

(JSC::SparseArrayValueMap::putDirect):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp

    r209897 r210457  
    138138    SparseArrayEntry& entry = result.iterator->value;
    139139
    140     if (mode != PutDirectIndexLikePutDirect && !array->isStructureExtensible()) {
    141         // To save a separate find & add, we first always add to the sparse map.
    142         // In the uncommon case that this is a new property, and the array is not
    143         // extensible, this is not the right thing to have done - so remove again.
    144         if (result.isNewEntry) {
    145             remove(result.iterator);
    146             return typeError(exec, scope, shouldThrow, ASCIILiteral(NonExtensibleObjectPropertyDefineError));
    147         }
    148         if (entry.attributes & ReadOnly)
    149             return typeError(exec, scope, shouldThrow, ASCIILiteral(ReadonlyPropertyWriteError));
    150     }
     140    // To save a separate find & add, we first always add to the sparse map.
     141    // In the uncommon case that this is a new property, and the array is not
     142    // extensible, this is not the right thing to have done - so remove again.
     143    if (mode != PutDirectIndexLikePutDirect && result.isNewEntry && !array->isStructureExtensible()) {
     144        remove(result.iterator);
     145        return typeError(exec, scope, shouldThrow, ASCIILiteral(NonExtensibleObjectPropertyDefineError));
     146    }
     147
     148    if (entry.attributes & ReadOnly)
     149        return typeError(exec, scope, shouldThrow, ASCIILiteral(ReadonlyPropertyWriteError));
     150
    151151    entry.attributes = attributes;
    152152    entry.set(vm, this, value);
Note: See TracChangeset for help on using the changeset viewer.