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

RAPIDJSON_ALIGN gives wrong results with x > 4 GB #418

Closed
segmtfault opened this issue Aug 31, 2015 · 1 comment
Closed

RAPIDJSON_ALIGN gives wrong results with x > 4 GB #418

segmtfault opened this issue Aug 31, 2015 · 1 comment
Labels

Comments

@segmtfault
Copy link

In rapidjson.h, with this definition:

ifndef RAPIDJSON_ALIGN

if RAPIDJSON_64BIT == 1

define RAPIDJSON_ALIGN(x) ((x + 7u) & ~7u)

~7u will generate a 32-bit bitmask (FFFF FFF8), thus giving incorrect values when x > 2^32 (4 GB).
For example, passing x = 4,901,136,555 will return 606,169,264

~7u should be changed to ~7llu (or ~7ull) to generate a 64-bit bitmask instead.

(Tested on VisualStudio 2012)

@miloyip miloyip added the bug label Sep 1, 2015
miloyip added a commit that referenced this issue Sep 1, 2015
Added unit tests for alignment macros.
Fixes #418
@miloyip
Copy link
Collaborator

miloyip commented Sep 1, 2015

Thank you for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants