Skip to content

Commit 13cae34

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 08e01a1 commit 13cae34

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
@@ -28,7 +28,7 @@ void Initialize(Local<Object> exports,
2828
node::Buffer::New(
2929
isolate,
3030
data,
31-
sizeof(data),
31+
sizeof(char),
3232
[](char* data, void* hint) {
3333
free_call_count++;
3434
},

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
@@ -32,7 +32,7 @@ NAPI_MODULE_INIT() {
3232
NAPI_CALL(env, napi_create_external_arraybuffer(
3333
env,
3434
data,
35-
sizeof(data),
35+
sizeof(char),
3636
finalize_cb,
3737
NULL,
3838
&buffer));

0 commit comments

Comments
 (0)