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 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.