Skip to content

Commit a3decc4

Browse files
committed
[squash] fix bug from targos’ review
1 parent 9db1853 commit a3decc4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/v8.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,12 @@ class DefaultSerializer extends Serializer {
140140
if (abView.constructor === Buffer) {
141141
i = bufferConstructorIndex;
142142
} else {
143-
i = arrayBufferViewTypeToIndex.get(objectToString(abView));
143+
const tag = objectToString(abView);
144+
i = arrayBufferViewTypeToIndex.get(tag);
145+
146+
if (i === undefined) {
147+
throw this._getDataCloneError(`Unknown host object type: ${tag}`);
148+
}
144149
}
145150
this.writeUint32(i);
146151
this.writeUint32(abView.byteLength);

test/parallel/test-v8-serdes.js

+5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ const objects = [
9999
}, /foobar/);
100100
}
101101

102+
{
103+
assert.throws(() => v8.serialize(process.stdin._handle),
104+
/^Error: Unknown host object type: \[object .*\]$/);
105+
}
106+
102107
{
103108
const buf = Buffer.from('ff0d6f2203666f6f5e007b01', 'hex');
104109

0 commit comments

Comments
 (0)