Skip to content

Commit

Permalink
Bug 1842773 - Part 22: Validate length is in-bounds for TypedArray it…
Browse files Browse the repository at this point in the history
…erator methods. r=sfink

Simply calls `PossiblyWrappedTypedArrayLength` which throws an error for
out-of-bounds TypedArrays.

Differential Revision: https://phabricator.services.mozilla.com/D183339
  • Loading branch information
anba committed Jan 26, 2024
1 parent 8511ee0 commit f4e48d7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions js/src/builtin/TypedArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ function TypedArrayEntries() {
// Step 2-6.
EnsureTypedArrayWithArrayBuffer(O);

// We also need to make sure the length is in-bounds. This is checked by
// calling PossiblyWrappedTypedArrayLength, which throws for out-of-bounds.
PossiblyWrappedTypedArrayLength(O);

// Step 7.
return CreateArrayIterator(O, ITEM_KIND_KEY_AND_VALUE);
}
Expand Down Expand Up @@ -697,6 +701,7 @@ function TypedArrayKeys() {

// Step 2.
EnsureTypedArrayWithArrayBuffer(O);
PossiblyWrappedTypedArrayLength(O);

// Step 3.
return CreateArrayIterator(O, ITEM_KIND_KEY);
Expand Down Expand Up @@ -1427,6 +1432,7 @@ function $TypedArrayValues() {

// See the big comment in TypedArrayEntries for what we're doing here.
EnsureTypedArrayWithArrayBuffer(O);
PossiblyWrappedTypedArrayLength(O);

// Step 7.
return CreateArrayIterator(O, ITEM_KIND_VALUE);
Expand Down

0 comments on commit f4e48d7

Please sign in to comment.