From af7da46d9bae0e3b69f6a7c53317c661cc61c327 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 28 Apr 2020 04:53:52 +0200 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/33115 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/addons/worker-buffer-callback/binding.cc | 2 +- .../test_worker_buffer_callback/test_worker_buffer_callback.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/addons/worker-buffer-callback/binding.cc b/test/addons/worker-buffer-callback/binding.cc index f600f410c1ed18..ac4c0cb498b7c7 100644 --- a/test/addons/worker-buffer-callback/binding.cc +++ b/test/addons/worker-buffer-callback/binding.cc @@ -30,7 +30,7 @@ void Initialize(Local exports, node::Buffer::New( isolate, data, - sizeof(data), + sizeof(char), [](char* data, void* hint) { delete data; free_call_count++; diff --git a/test/node-api/test_worker_buffer_callback/test_worker_buffer_callback.c b/test/node-api/test_worker_buffer_callback/test_worker_buffer_callback.c index 3275551aee526a..b4f2e288ece31b 100644 --- a/test/node-api/test_worker_buffer_callback/test_worker_buffer_callback.c +++ b/test/node-api/test_worker_buffer_callback/test_worker_buffer_callback.c @@ -35,7 +35,7 @@ NAPI_MODULE_INIT() { NAPI_CALL(env, napi_create_external_arraybuffer( env, data, - sizeof(data), + sizeof(char), finalize_cb, NULL, &buffer));