Fixes issue #94521: Make sure to always specify Uint32Array length in ctor

This commit is contained in:
Alex Dima
2020-04-06 13:39:10 +02:00
parent deb33e0adf
commit 8918d05cb5
2 changed files with 28 additions and 2 deletions

View File

@@ -55,12 +55,12 @@ function fromLittleEndianBuffer(buff: VSBuffer): Uint32Array {
reverseEndianness(uint8Arr);
}
if (uint8Arr.byteOffset % 4 === 0) {
return new Uint32Array(uint8Arr.buffer, uint8Arr.byteOffset);
return new Uint32Array(uint8Arr.buffer, uint8Arr.byteOffset, uint8Arr.length / 4);
} else {
// unaligned memory access doesn't work on all platforms
const data = new Uint8Array(uint8Arr.byteLength);
data.set(uint8Arr);
return new Uint32Array(data.buffer, data.byteOffset);
return new Uint32Array(data.buffer, data.byteOffset, data.length / 4);
}
}