Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
worker: copy transferList ArrayBuffers on unknown allocator
Browse files Browse the repository at this point in the history
If the `ArrayBuffer::Allocator` used to create `ArrayBuffer`s
in the current `Isolate` is not a Node.js `ArrayBufferAllocator`,
we cannot know that it is `malloc()`-based, an in particular it might
not be compatible with the `ArrayBuffer::Allocator` on the receiving
end of the connection.

PR-URL: nodejs/node#26207
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
addaleax authored and deepak1556 committed Jul 10, 2019
1 parent 5538126 commit 6418b51
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ Maybe<bool> Message::Serialize(Environment* env,
Local<ArrayBuffer> ab = entry.As<ArrayBuffer>();
// If we cannot render the ArrayBuffer unusable in this Isolate and
// take ownership of its memory, copying the buffer will have to do.
if (!ab->IsNeuterable() || ab->IsExternal())
if (!ab->IsNeuterable() || ab->IsExternal() ||
!env->isolate_data()->uses_node_allocator()) {
continue;
}
// We simply use the array index in the `array_buffers` list as the
Expand Down

0 comments on commit 6418b51

Please sign in to comment.