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:
parent
0057f6744a
commit
d1ee793b75
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue