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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
addaleax authored and targos committed May 4, 2020
1 parent 9ccb6b2 commit af7da46
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void Initialize(Local<Object> exports,
node::Buffer::New(
isolate,
data,
sizeof(data),
sizeof(char),
[](char* data, void* hint) {
delete data;
free_call_count++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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 af7da46

Please sign in to comment.