Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant