mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
src: readiterable entries may be empty
fixup PR-URL: https://github.com/nodejs/node/pull/50398 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This commit is contained in:
1 parent
8eea2d3709
commit
e2cf2f0fda
3 files changed
+28
-2
No files matched your search
@@ -1003,8 +1003,11 @@ static Maybe<bool> ReadIterable(Environment* env,
|
||||
entries.push_back(val);
|
||||
}
|
||||
|
||||
transfer_list.AllocateSufficientStorage(entries.size());
|
||||
std::copy(entries.begin(), entries.end(), &transfer_list[0]);
|
||||
if (!entries.empty()) {
|
||||
transfer_list.AllocateSufficientStorage(entries.size());
|
||||
std::copy(entries.begin(), entries.end(), &transfer_list[0]);
|
||||
}
|
||||
|
||||
return Just(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
|
||||
// See: https://github.com/nodejs/node/issues/49940
|
||||
(async () => {
|
||||
new MessageChannel().port1.postMessage({}, {
|
||||
transfer: {
|
||||
*[Symbol.iterator]() {}
|
||||
}
|
||||
});
|
||||
})().then(common.mustCall());
|
||||
@@ -15,3 +15,14 @@ assert.strictEqual(structuredClone(undefined, null), undefined);
|
||||
// Transfer can be null or undefined.
|
||||
assert.strictEqual(structuredClone(undefined, { transfer: null }), undefined);
|
||||
assert.strictEqual(structuredClone(undefined, { }), undefined);
|
||||
|
||||
{
|
||||
// See: https://github.com/nodejs/node/issues/49940
|
||||
const cloned = structuredClone({}, {
|
||||
transfer: {
|
||||
*[Symbol.iterator]() {}
|
||||
}
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(cloned, {});
|
||||
}
|
||||
Reference in new issue
Block a user