Skip to content

Commit af7da46

Browse files
addaleaxtargos
authored andcommitted
test: fix out-of-bound reads from invalid sizeof usage
`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>
1 parent 9ccb6b2 commit af7da46

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

test/addons/worker-buffer-callback/binding.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void Initialize(Local<Object> exports,
3030
node::Buffer::New(
3131
isolate,
3232
data,
33-
sizeof(data),
33+
sizeof(char),
3434
[](char* data, void* hint) {
3535
delete data;
3636
free_call_count++;

test/node-api/test_worker_buffer_callback/test_worker_buffer_callback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ NAPI_MODULE_INIT() {
3535
NAPI_CALL(env, napi_create_external_arraybuffer(
3636
env,
3737
data,
38-
sizeof(data),
38+
sizeof(char),
3939
finalize_cb,
4040
NULL,
4141
&buffer));

0 commit comments

Comments
 (0)