8000 Fix decoding of signed varint32s. · benjaminp/protobuf-javascript@d7f3c7a · GitHub
[go: up one dir, main page]

Skip to content

Commit d7f3c7a

Browse files
authored
Fix decoding of signed varint32s.
1 parent cb8c3ab commit d7f3c7a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

binary/decoder.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,13 @@ jspb.BinaryDecoder.prototype.readUnsignedVarint32 = function() {
481481

482482

483483
/**
484-
* The readUnsignedVarint32 above deals with signed 32-bit varints correctly,
485-
* so this is just an alias.
484+
* Coerces the output of readUnsignedVarint32 to an int32.
486485
*
487486
* @return {number} The decoded signed 32-bit varint.
488487
*/
489-
jspb.BinaryDecoder.prototype.readSignedVarint32 =
490-
jspb.BinaryDecoder.prototype.readUnsignedVarint32;
488+
jspb.BinaryDecoder.prototype.readSignedVarint32 = function() {
489+
return ~~(this.readUnsignedVarint32());
490+
}
491491

492492

493493
/**

0 commit comments

Comments
 (0)
0