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

js/binary/utils.js: Fix jspb.utils.joinUnsignedDecimalString to work with negative bitsLow and low but non-zero bitsHigh parameter. #8170

Merged
merged 1 commit into from Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions js/binary/decoder_test.js
Expand Up @@ -315,6 +315,9 @@ describe('binaryDecoderTest', function() {
// 64-bit extremes, not in dev guide.
{original: '9223372036854775807', zigzag: '18446744073709551614'},
{original: '-9223372036854775808', zigzag: '18446744073709551615'},
// None of the above catch: bitsLow < 0 && bitsHigh > 0 && bitsHigh < 0x1FFFFF.
// The following used to be broken.
{original: '72000000000', zigzag: '144000000000'},
];
var encoder = new jspb.BinaryEncoder();
testCases.forEach(function(c) {
Expand Down
2 changes: 1 addition & 1 deletion js/binary/utils.js
Expand Up @@ -511,7 +511,7 @@ jspb.utils.joinUnsignedDecimalString = function(bitsLow, bitsHigh) {
// Skip the expensive conversion if the number is small enough to use the
// built-in conversions.
if (bitsHigh <= 0x1FFFFF) {
return '' + (jspb.BinaryConstants.TWO_TO_32 * bitsHigh + bitsLow);
return '' + jspb.utils.joinUint64(bitsLow, bitsHigh);
}

// What this code is doing is essentially converting the input number from
Expand Down