Skip to content

Commit 2e5a12d

Browse files
authored
js/binary/utils.js: Fix jspb.utils.joinUnsignedDecimalString to work with negative bitsLow and low but non-zero bitsHigh parameter. (#8170)
1 parent 255a6a3 commit 2e5a12d

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

binary/decoder_test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ describe('binaryDecoderTest', function() {
315315
// 64-bit extremes, not in dev guide.
316316
{original: '9223372036854775807', zigzag: '18446744073709551614'},
317317
{original: '-9223372036854775808', zigzag: '18446744073709551615'},
318+
// None of the above catch: bitsLow < 0 && bitsHigh > 0 && bitsHigh < 0x1FFFFF.
319+
// The following used to be broken.
320+
{original: '72000000000', zigzag: '144000000000'},
318321
];
319322
var encoder = new jspb.BinaryEncoder();
320323
testCases.forEach(function(c) {

binary/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ jspb.utils.joinUnsignedDecimalString = function(bitsLow, bitsHigh) {
511511
// Skip the expensive conversion if the number is small enough to use the
512512
// built-in conversions.
513513
if (bitsHigh <= 0x1FFFFF) {
514-
return '' + (jspb.BinaryConstants.TWO_TO_32 * bitsHigh + bitsLow);
514+
return '' + jspb.utils.joinUint64(bitsLow, bitsHigh);
515515
}
516516

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

0 commit comments

Comments
 (0)