Use size of the typed array instead of underlying bufffer

If an array is subarrayed from another array they will still have the same underlying buffer giving the wrong size here
This commit is contained in:
AlexVestin 2020-04-22 17:25:25 +02:00 committed by GitHub
parent 0057f6744a
commit d1ee793b75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -338,7 +338,7 @@ inline Type* getArrayData(
size_t offset = ta.ByteOffset(); size_t offset = ta.ByteOffset();
Napi::ArrayBuffer arr = ta.ArrayBuffer(); Napi::ArrayBuffer arr = ta.ArrayBuffer();
if (num) { if (num) {
*num = arr.ByteLength() / sizeof(Type); *num = ta.ByteLength() / sizeof(Type);
} }
uint8_t *base = reinterpret_cast<uint8_t *>(arr.Data()); uint8_t *base = reinterpret_cast<uint8_t *>(arr.Data());
out = reinterpret_cast<Type *>(base + offset); out = reinterpret_cast<Type *>(base + offset);