pierrec / node-lz4

LZ4 fast compression algorithm for NodeJS
MIT License
438 stars 98 forks source link

Uncaught RangeError: "value" argument is out of bounds #107

Closed podlomar closed 3 years ago

podlomar commented 3 years ago

The library crashes inside browser on a very simple input with blockChecksum enabled.

Code:

const Buffer = require('buffer').Buffer;
const LZ4 = require('lz4');
const input = Buffer.from('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
LZ4.encode(input, { blockChecksum: true });

Error in console:

Uncaught RangeError: "value" argument is out of bounds
    at checkInt (lz4.min.js:8912)
    at Uint8Array.writeInt32LE (lz4.min.js:9079)
    at Encoder.compress_DataBlock (lz4.min.js:819)
    at Encoder._flush (lz4.min.js:877)
    at Encoder.prefinish (lz4.min.js:4583)
    at emitNone (lz4.min.js:2430)
    at Encoder.emit (lz4.min.js:2515)
    at prefinish (lz4.min.js:5280)
    at finishMaybe (lz4.min.js:5288)
    at endWritable (lz4.min.js:5299)

I am not sure why this happens and if I am doing something wrong or if this is a bug.