Skip to content

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: nodejs#259
Reviewed-By: Hitesh Kanwathirtha <[email protected]>
Reviewed-By: Kunal Pathak <[email protected]>
Reviewed-By: Taylor Woll <[email protected]>
Reviewed-By: Kyle Farnung <[email protected]>
  • Loading branch information
jasongin committed May 25, 2017
1 parent ff36192 commit 04f48ad
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 04f48ad

Please sign in to comment.