Skip to content

Commit

Permalink
[squash] fix bug from targos’ review
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Mar 27, 2017
1 parent 9db1853 commit a3decc4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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}`);
}
}
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

0 comments on commit a3decc4

Please sign in to comment.