File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -685,7 +685,8 @@ public JsonToken nextToken() throws IOException
685
685
{
686
686
int v = _decode32Bits ();
687
687
if (v < 0 ) {
688
- _numberLong = ((long ) v ) + -1L ;
688
+ long unsignedBase = (long ) v & 0xFFFFFFFFL ;
689
+ _numberLong = -unsignedBase - 1L ;
689
690
_numTypesValid = NR_LONG ;
690
691
} else {
691
692
_numberInt = -v - 1 ;
@@ -700,7 +701,8 @@ public JsonToken nextToken() throws IOException
700
701
_numberLong = -l - 1L ;
701
702
_numTypesValid = NR_LONG ;
702
703
} else {
703
- _numberBigInt = _bigNegative (l );
704
+ BigInteger unsignedBase = _bigPositive (l );
705
+ _numberBigInt = unsignedBase .negate ().subtract (BigInteger .ONE );
704
706
_numTypesValid = NR_BIGINT ;
705
707
}
706
708
}
@@ -1158,7 +1160,8 @@ public String nextTextValue() throws IOException
1158
1160
{
1159
1161
int v = _decode32Bits ();
1160
1162
if (v < 0 ) {
1161
- _numberLong = ((long ) v ) + -1L ;
1163
+ long unsignedBase = (long ) v & 0xFFFFFFFFL ;
1164
+ _numberLong = -unsignedBase - 1L ;
1162
1165
_numTypesValid = NR_LONG ;
1163
1166
} else {
1164
1167
_numberInt = -v - 1 ;
@@ -1173,7 +1176,8 @@ public String nextTextValue() throws IOException
1173
1176
_numberLong = l ;
1174
1177
_numTypesValid = NR_LONG ;
1175
1178
} else {
1176
- _numberBigInt = _bigNegative (l );
1179
+ BigInteger unsignedBase = _bigPositive (l );
1180
+ _numberBigInt = unsignedBase .negate ().subtract (BigInteger .ONE );
1177
1181
_numTypesValid = NR_BIGINT ;
1178
1182
}
1179
1183
}
You can’t perform that action at this time.
0 commit comments