@@ -400,7 +400,22 @@ public int getIntValue() throws IOException {
400
400
// @since 2.17
401
401
private int _getIntValue () throws IOException {
402
402
try {
403
- return _reader .intValue ();
403
+ if (getNumberType () == NumberType .LONG ) {
404
+ int result = _reader .intValue ();
405
+ if ((long ) result != _reader .longValue ()) {
406
+ this .reportOverflowInt ();
407
+ }
408
+ return result ;
409
+ }
410
+ if (getNumberType () == NumberType .BIG_INTEGER ) {
411
+ BigInteger bigInteger = _reader .bigIntegerValue ();
412
+ if (BI_MIN_INT .compareTo (bigInteger ) > 0 || BI_MAX_INT .compareTo (bigInteger ) < 0 ) {
413
+ this .reportOverflowInt ();
414
+ }
415
+ return bigInteger .intValue ();
416
+ } else {
417
+ return _reader .intValue ();
418
+ }
404
419
} catch (IonException
405
420
// 15-Jan-2024, tatu: other OSS-Fuzz tests suggest we need this:
406
421
| ArrayIndexOutOfBoundsException e ) {
@@ -417,7 +432,15 @@ public long getLongValue() throws IOException {
417
432
// @since 2.17
418
433
private long _getLongValue () throws IOException {
419
434
try {
420
- return _reader .longValue ();
435
+ if (this .getNumberType () == NumberType .BIG_INTEGER ) {
436
+ BigInteger bigInteger = _reader .bigIntegerValue ();
437
+ if (BI_MIN_INT .compareTo (bigInteger ) > 0 || BI_MAX_INT .compareTo (bigInteger ) < 0 ) {
438
+ this .reportOverflowLong ();
439
+ }
440
+ return bigInteger .longValue ();
441
+ } else {
442
+ return _reader .longValue ();
443
+ }
421
444
} catch (IonException
422
445
// 14-Jan-2024, tatu: OSS-Fuzz#65731 points to AIOOBE:
423
446
| ArrayIndexOutOfBoundsException e ) {
0 commit comments