mcollina / msgpack5

A msgpack v5 implementation for node.js, with extension points / msgpack.org[Node]
MIT License
492 stars 76 forks source link

Produces invalid msgpack when encoding sparse arrays #91

Closed ninevra closed 3 years ago

ninevra commented 3 years ago

Encoding sparse arrays produces corrupted data. Decoding the result of encoding a sparse array throws IncompleteBufferError.

const m = require('msgpack5'();
m.encode(new Array(4)); // returns <Buffer 94>
m.decode(m.encode(new Array(4)); // throws IncompleteBufferError: unable to decode

Probably this should throw at encode().