mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Fix buffer access bug in builtinTypedArrayCopyWithin
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
0a79d6c1f7
commit
f95e7fe59e
1 changed files with 3 additions and 1 deletions
|
|
@ -485,7 +485,9 @@ static Value builtinTypedArrayCopyWithin(ExecutionState& state, Value thisValue,
|
|||
// Set len to TypedArrayLength(taRecord).
|
||||
len = O->arrayLength();
|
||||
// Set count to min(count, len - startIndex, len - targetIndex).
|
||||
count = std::min(std::min(count, len - startIndex), len - targetIndex);
|
||||
// NOTE: After buffer resize during argument coercion, len - startIndex or len - targetIndex can be negative.
|
||||
// We must clamp count to non-negative to prevent integer underflow when casting to size_t.
|
||||
count = std::max(0.0, std::min(std::min(count, len - startIndex), len - targetIndex));
|
||||
// Let typedArrayName be the String value of O.[[TypedArrayName]].
|
||||
// Let elementSize be the Number value of the Element Size value specified in Table 59 for typedArrayName.
|
||||
size_t elementSize = O->elementSize();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue