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 <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Anna Henningsen 2020-04-28 04:53:52 +02:00
parent ff38ec0471
commit 8698dd98bb
No known key found for this signature in database
GPG Key ID: A94130F0BFC8EBE9
2 changed files with 2 additions and 2 deletions

View File

@ -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++;

View File

@ -35,7 +35,7 @@ NAPI_MODULE_INIT() {
NAPI_CALL(env, napi_create_external_arraybuffer(
env,
data,
sizeof(data),
sizeof(char),
finalize_cb,
NULL,
&buffer));