Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 3ba84d2

Browse files
authored
Normative: Correct buffer limit checks in TypedArray.p.slice (#127)
The limit has to take `targetByteIndex` into account, too.
1 parent 4d6f85e commit 3ba84d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

spec.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ <h1>%TypedArray%.prototype.slice ( _start_, _end_ )</h1>
806806
1. Perform ? ValidateTypedArray(_O_).
807807
1. <ins>Let _getBufferByteLength_ be MakeIdempotentArrayBufferByteLengthGetter(~SeqCst~).</ins>
808808
1. Let _len_ be <del>_O_.[[ArrayLength]]</del><ins>IntegerIndexedObjectLength(_O_, _getBufferByteLength_)</ins>.
809+
1. <ins>Assert: _len_ is not ~out-of-bounds~.</ins>
809810
1. Let _relativeStart_ be ? ToIntegerOrInfinity(_start_).
810811
1. If _relativeStart_ is -&infin;, let _k_ be 0.
811812
1. Else if _relativeStart_ &lt; 0, let _k_ be max(_len_ + _relativeStart_, 0).
@@ -842,7 +843,7 @@ <h1>%TypedArray%.prototype.slice ( _start_, _end_ )</h1>
842843
1. Let _srcByteOffset_ be _O_.[[ByteOffset]].
843844
1. Let _targetByteIndex_ be _A_.[[ByteOffset]].
844845
1. Let _srcByteIndex_ be (_k_ &times; _elementSize_) + _srcByteOffset_.
845-
1. Let _limit_ be <ins>min(</ins>_targetByteIndex_ + _count_ &times; _elementSize_<ins>, _len_ &times; _elementSize_)</ins>.
846+
1. Let _limit_ be _targetByteIndex_ + <ins>min(</ins>_count_<ins>, _len_)</ins> &times; _elementSize_.
846847
1. Repeat, while _targetByteIndex_ &lt; _limit_,
847848
1. Let _value_ be GetValueFromBuffer(_srcBuffer_, _srcByteIndex_, ~Uint8~, *true*, ~Unordered~).
848849
1. Perform SetValueInBuffer(_targetBuffer_, _targetByteIndex_, ~Uint8~, _value_, *true*, ~Unordered~).

0 commit comments

Comments
 (0)