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 zigzag encoding overflow #31

Open
anandthakker opened this issue May 14, 2018 · 0 comments
Open

Fix zigzag encoding overflow #31

anandthakker opened this issue May 14, 2018 · 0 comments

Comments

@anandthakker
Copy link
Contributor

The current bit-shifting arithmetic for zigzag encoding:

vt-pbf/index.js

Lines 125 to 127 in ad933a6

function zigzag (num) {
return (num << 1) ^ (num >> 31)
}

overflows for 2^31 - 1, because JavaScript bit-shifting yields signed 32-bit integers: https://www.ecma-international.org/ecma-262/5.1/#sec-11.7.1

This is unlikely to matter in practice, given that tile extents are typically 4096 or 8192

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