Skip to content

Commit b76ba0f

Browse files
author
Atul Katti
committed
[1.4>master] [MERGE #2350 @atulkatti] Revert the earlier TypedArray change as it may lead to integer overflow.
Merge pull request #2350 from atulkatti:TypedArray.Bug10450472
2 parents 58a7226 + cf864b3 commit b76ba0f

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

lib/Runtime/Library/TypedArray.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ namespace Js
388388
Var TypedArrayBase::CreateNewInstance(Arguments& args, ScriptContext* scriptContext, uint32 elementSize, PFNCreateTypedArray pfnCreateTypedArray)
389389
{
390390
uint32 byteLength = 0;
391-
uint32 newByteLength = 0;
392391
int32 offset = 0;
393392
int32 mappedLength = -1;
394393
uint32 elementCount = 0;
@@ -509,16 +508,7 @@ namespace Js
509508

510509
if (args.Info.Count > 3 && !JavascriptOperators::IsUndefinedObject(args[3]))
511510
{
512-
mappedLength = ArrayBuffer::ToIndex(args[3], JSERR_InvalidTypedArrayLength, scriptContext, ArrayBuffer::MaxArrayBufferLength / elementSize, false);
513-
newByteLength = mappedLength * elementSize;
514-
515-
if (offset + newByteLength > byteLength)
516-
{
517-
JavascriptError::ThrowRangeError(
518-
scriptContext, JSERR_InvalidTypedArrayLength);
519-
}
520-
521-
byteLength = newByteLength;
511+
mappedLength = ArrayBuffer::ToIndex(args[3], JSERR_InvalidTypedArrayLength, scriptContext, (byteLength - offset) / elementSize, false);
522512
}
523513
else
524514
{

0 commit comments

Comments
 (0)