Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Fix RangeError caused by streamSize in encoder #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

constfold
Copy link

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.

1. Fixed headerSize gives an incorrect length(streamSizeSize should be 8
instead 2)
2. Fixed endian issue of streamSize (it was BE instead LE)
3. Fixed streamSize not exactly the size of input
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant