Skip to content

Commit

Permalink
test: fix out-of-bound reads from invalid sizeof usage
Browse files Browse the repository at this point in the history
`sizeof(data)` does not return the correct result here, as it measures
the size of the `data` variable, not what it points to.

PR-URL: #33115
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and targos committed May 13, 2020
1 parent 08e01a1 commit 13cae34
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/addons/worker-buffer-callback/binding.cc
Expand Up @@ -28,7 +28,7 @@ void Initialize(Local<Object> exports,
node::Buffer::New(
isolate,
data,
sizeof(data),
sizeof(char),
[](char* data, void* hint) {
free_call_count++;
},
Expand Down
Expand Up @@ -32,7 +32,7 @@ NAPI_MODULE_INIT() {
NAPI_CALL(env, napi_create_external_arraybuffer(
env,
data,
sizeof(data),
sizeof(char),
finalize_cb,
NULL,
&buffer));
Expand Down

0 comments on commit 13cae34

Please sign in to comment.