Skip to content

Commit fcf4e88

Browse files
fix tests
1 parent 1d8a5ea commit fcf4e88

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/parse.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,13 @@ export function unflatten(parsed, revivers) {
145145
case 'BigUint64Array': {
146146
if (values[value[1]][0] !== 'ArrayBuffer') {
147147
// without this, if we receive malformed input we could
148-
// end up trying to hydrate in a circle
148+
// end up trying to hydrate in a circle or allocate
149+
// huge amounts of memory when we call `new TypedArrayConstructor(buffer)`
149150
throw new Error('Invalid data');
150151
}
151152

152153
const TypedArrayConstructor = globalThis[type];
153154
const buffer = hydrate(value[1]);
154-
if (!(buffer instanceof ArrayBuffer)) {
155-
throw new Error(`Invalid input, expected ArrayBuffer but got ${typeof buffer}`);
156-
}
157155
const typedArray = new TypedArrayConstructor(buffer);
158156

159157
hydrated[index] =

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ const invalid = [
743743
{
744744
name: 'typed array with non-ArrayBuffer input',
745745
json: '[["Int8Array", 1], { "length": 2 }, 1000000000]',
746-
message: 'Invalid input, expected ArrayBuffer but got object'
746+
message: 'Invalid data'
747747
},
748748
{
749749
name: 'ArrayBuffer with non-string value',

0 commit comments

Comments
 (0)