diff options
| author | Keyhan Vakil <kvakil@github.kvakil.me> | 2022-07-24 16:06:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-25 00:06:08 +0100 |
| commit | e8e92ec2d10ecbe952a8adbe559e217e67368904 (patch) | |
| tree | 049025e9bd7a71c6074a4248ba195ecfc9444313 /src/node_buffer.cc | |
| parent | f9b7380b42a403f299324ba6edb52954e2dbbe9f (diff) | |
| download | node-new-e8e92ec2d10ecbe952a8adbe559e217e67368904.tar.gz | |
buffer: do not leak memory if buffer is too big
A recent pull request changed this method to throw when the buffer was
too big, but this meant that the `free` finalizer would never get
called, leading to a memory leak.
A previous version of this diff included a test provoking this behavior
with `v8.serialize`, but it unfortunately kept triggering the OOM
killer, so it was removed.
Refs: https://github.com/nodejs/node/pull/40243
PR-URL: https://github.com/nodejs/node/pull/43938
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/node_buffer.cc')
| -rw-r--r-- | src/node_buffer.cc | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 5b2186feb8..aec97f15e2 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -497,6 +497,7 @@ MaybeLocal<Object> New(Environment* env, if (length > kMaxLength) { Isolate* isolate(env->isolate()); isolate->ThrowException(ERR_BUFFER_TOO_LARGE(isolate)); + free(data); return Local<Object>(); } } |
