Repository navigation
Encode uint64 values above INT64_MAX in UBJSON - #753
Merged
danielaparker merged 2 commits intoOct 7, 2026
Merged
Conversation
visit_uint64 wrote nothing for values above INT64_MAX but still counted the element, so the output declared more elements than it held. Write them as high-precision numbers, as the encoder does for bigint strings.
Owner
|
Thanks for contributing! I would suggest replacing for (auto c : s)
{
sink_.push_back(c);
}with sink_.append(s.data(), s.size());Otherwise it's fine. |
Contributor
Author
|
Thanks, done in d5f5fcf. The bytes sink's |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
encode_ubjsonwrites nothing for auint64_tvalue aboveINT64_MAXbut still counts it as a container element.[9223372036854775808]becomes5b235501(an array that declares one element and contains none), and a top-level value becomes an empty buffer;decode_ubjsonand other UBJSON readers reject both.UBJSON has no unsigned 64-bit type, so this writes such values as high-precision numbers (
H), as the encoder already does for bigint strings; the parser reads them back assemantic_tag::bigint. The bytes match py-ubjson's encoding of the same values.Added a test with the exact bytes and a
decode_ubjsonround trip, plus a guard thatINT64_MAXstaysL. The ubjson tests pass under ASan/UBSan.Written with AI assistance (Claude); I have reviewed the change.