Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[squash] fix bug from targos’ review
  • Loading branch information
addaleax committed Mar 27, 2017
commit a3decc4cb9515ea36aed3df7392a0aaf7467a27f
7 changes: 6 additions & 1 deletion lib/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ class DefaultSerializer extends Serializer {
if (abView.constructor === Buffer) {
i = bufferConstructorIndex;
} else {
i = arrayBufferViewTypeToIndex.get(objectToString(abView));
const tag = objectToString(abView);
i = arrayBufferViewTypeToIndex.get(tag);

if (i === undefined) {
throw this._getDataCloneError(`Unknown host object type: ${tag}`);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this throw an error when i is undefined (unknown host object)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@targos Yes thanks for catching! Updated + test added

this.writeUint32(i);
this.writeUint32(abView.byteLength);
Expand Down
5 changes: 5 additions & 0 deletions test/parallel/test-v8-serdes.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ const objects = [
}, /foobar/);
}

{
assert.throws(() => v8.serialize(process.stdin._handle),
/^Error: Unknown host object type: \[object .*\]$/);
}

{
const buf = Buffer.from('ff0d6f2203666f6f5e007b01', 'hex');

Expand Down