Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
n-api: fix TypedAarray info for ArrayBuffer offset
Browse files Browse the repository at this point in the history
The JsGetTypedArrayStorage API returns a buffer pointer that already
incorporates the offset into the ArrayBuffer, so adding the offset
was a mistake.

This bug was caught by the N-API C++ wrapper tests at
https://github.com/nodejs/node-addon-api/blob/master/test/typedarray.js

PR-URL: #259
Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
Reviewed-By: Kunal Pathak <kpathak@microsoft.com>
Reviewed-By: Taylor Woll <taylor.woll@microsoft.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
  • Loading branch information
jasongin authored and kfarnung committed Jun 5, 2017
1 parent 3a047d7 commit cebc14a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/node_api_jsrt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1995,7 +1995,7 @@ napi_status napi_get_typedarray_info(napi_env env,
}

if (data != nullptr) {
*data = static_cast<uint8_t*>(bufferData) + byteOffset;
*data = static_cast<uint8_t*>(bufferData);
}

if (arraybuffer != nullptr) {
Expand Down

0 comments on commit cebc14a

Please sign in to comment.