| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bd5b61f commit 4eb74a2
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1003,8 +1003,11 @@ static Maybe<bool> ReadIterable(Environment* env, | |||
| 1003 | 1003 | entries.push_back(val); | |
| 1004 | 1004 | } | |
| 1005 | 1005 | ||
| 1006 | - transfer_list.AllocateSufficientStorage(entries.size()); | ||
| 1007 | - std::copy(entries.begin(), entries.end(), &transfer_list[0]); | ||
| 1006 | + if (!entries.empty()) { | ||
| 1007 | + transfer_list.AllocateSufficientStorage(entries.size()); | ||
| 1008 | + std::copy(entries.begin(), entries.end(), &transfer_list[0]); | ||
| 1009 | + } | ||
| 1010 | + | ||
| 1008 | 1011 | return Just(true); | |
| 1009 | 1012 | } | |
| 1010 | 1013 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,12 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + | ||
| 5 | + // See: https://github.com/nodejs/node/issues/49940 | ||
| 6 | + (async () => { | ||
| 7 | + new MessageChannel().port1.postMessage({}, { | ||
| 8 | + transfer: { | ||
| 9 | + *[Symbol.iterator]() {} | ||
| 10 | + } | ||
| 11 | + }); | ||
| 12 | + })().then(common.mustCall()); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,3 +15,14 @@ assert.strictEqual(structuredClone(undefined, null), undefined); | |||
| 15 | 15 | // Transfer can be null or undefined. | |
| 16 | 16 | assert.strictEqual(structuredClone(undefined, { transfer: null }), undefined); | |
| 17 | 17 | assert.strictEqual(structuredClone(undefined, { }), undefined); | |
| 18 | + | ||
| 19 | + { | ||
| 20 | + // See: https://github.com/nodejs/node/issues/49940 | ||
| 21 | + const cloned = structuredClone({}, { | ||
| 22 | + transfer: { | ||
| 23 | + *[Symbol.iterator]() {} | ||
| 24 | + } | ||
| 25 | + }); | ||
| 26 | + | ||
| 27 | + assert.deepStrictEqual(cloned, {}); | ||
| 28 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments