| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 437bb25 commit 20dc172
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -132,6 +132,18 @@ MaybeLocal<Value> Message::Deserialize(Environment* env, | |||
| 132 | 132 | ||
| 133 | 133 | // Attach all transferred ArrayBuffers to their new Isolate. | |
| 134 | 134 | for (uint32_t i = 0; i < array_buffer_contents_.size(); ++i) { | |
| 135 | + if (!env->isolate_data()->uses_node_allocator()) { | ||
| 136 | + // We don't use Node's allocator on the receiving side, so we have | ||
| 137 | + // to create the ArrayBuffer from a copy of the memory. | ||
| 138 | + AllocatedBuffer buf = | ||
| 139 | + env->AllocateManaged(array_buffer_contents_[i].size); | ||
| 140 | + memcpy(buf.data(), | ||
| 141 | + array_buffer_contents_[i].data, | ||
| 142 | + array_buffer_contents_[i].size); | ||
| 143 | + deserializer.TransferArrayBuffer(i, buf.ToArrayBuffer()); | ||
| 144 | + continue; | ||
| 145 | + } | ||
| 146 | + | ||
| 135 | 147 | Local<ArrayBuffer> ab = | |
| 136 | 148 | ArrayBuffer::New(env->isolate(), | |
| 137 | 149 | array_buffer_contents_[i].release(), | |
@@ -288,8 +300,10 @@ Maybe<bool> Message::Serialize(Environment* env, | |||
| 288 | 300 | Local<ArrayBuffer> ab = entry.As<ArrayBuffer>(); | |
| 289 | 301 | // If we cannot render the ArrayBuffer unusable in this Isolate and | |
| 290 | 302 | // take ownership of its memory, copying the buffer will have to do. | |
| 291 | - if (!ab->IsNeuterable() || ab->IsExternal()) | ||
| 303 | + if (!ab->IsNeuterable() || ab->IsExternal() || | ||
| 304 | + !env->isolate_data()->uses_node_allocator()) { | ||
| 292 | 305 | continue; | |
| 306 | + } | ||
| 293 | 307 | if (std::find(array_buffers.begin(), array_buffers.end(), ab) != | |
| 294 | 308 | array_buffers.end()) { | |
| 295 | 309 | ThrowDataCloneException( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments