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

Use Buffer slice will have wrong result when end is larger than int32. #315

Open
Dhuliang opened this issue Jun 1, 2022 · 0 comments
Open

Comments

@Dhuliang
Copy link

Dhuliang commented Jun 1, 2022

[1,2,3].slice(1,3) return  [2, 3], it's ok.

Array.from( Buffer.from([1,2,3]).slice(1,3) ) return [2,3], it's ok.

Array.from( Buffer.from([1,2,3]).slice(1,Math.pow(2,32)) ) return [] , it's wrong result.

In node Buffer, there is comment:
// Use Math.trunc() to convert offset to an integer value that can be larger
// than an Int32. Hence, don't use offset | 0 or similar techniques.

In this package, Buffer use ~, can't work with larger than int32 number.

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

No branches or pull requests

1 participant