pierrec / node-lz4

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

Fix RangeError caused by streamSize in encoder #120

Open constfold opened 7 months ago

constfold commented 7 months ago

Before this patch, there was an error in encoder when set streamSize to true:

Uncaught RangeError RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 0. Received 2
    at __node_internal_captureLargerStackTrace (internal/errors:464:5)
    at NodeError (internal/errors:371:5)
    at boundsError (internal/buffer:86:9)
    at checkBounds (internal/buffer:55:5)
    at checkInt (internal/buffer:74:3)
    at writeU_Int32LE (internal/buffer:692:3)
    at writeInt32LE (internal/buffer:861:10)

This PR fixed the error and also added a simple test.