Skip to content

Commit a51fb6d

Browse files
committed
Start work on #488
1 parent 105102b commit a51fb6d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/main/java/com/fasterxml/jackson/core/base/ParserBase.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ private void _parseSlowFloat(int expType) throws IOException
826826
_wrapError("Malformed numeric value '"+_textBuffer.contentsAsString()+"'", nex);
827827
}
828828
}
829-
829+
830830
private void _parseSlowInt(int expType) throws IOException
831831
{
832832
String numStr = _textBuffer.contentsAsString();
@@ -843,6 +843,10 @@ private void _parseSlowInt(int expType) throws IOException
843843
_numberLong = Long.parseLong(numStr);
844844
_numTypesValid = NR_LONG;
845845
} else {
846+
// 16-Oct-2018, tatu: Need to catch "too big" early due to... issues
847+
if ((expType == NR_INT) || (expType == NR_LONG)) {
848+
_reportTooLongInt(expType, numStr);
849+
}
846850
// nope, need the heavy guns... (rare case)
847851
_numberBigInt = new BigInteger(numStr);
848852
_numTypesValid = NR_BIGINT;
@@ -852,7 +856,17 @@ private void _parseSlowInt(int expType) throws IOException
852856
_wrapError("Malformed numeric value '"+numStr+"'", nex);
853857
}
854858
}
855-
859+
860+
// @since 2.9.8
861+
protected void _reportTooLongInt(int expType, String rawNum) throws IOException
862+
{
863+
String numDesc = (rawNum.length() > 1000)
864+
? String.format("[Integer with %d digits]", rawNum.length())
865+
: rawNum;
866+
_reportError("Numeric value (%s) out of range of %s", numDesc,
867+
(expType == NR_LONG) ? "long" : "int");
868+
}
869+
856870
/*
857871
/**********************************************************
858872
/* Numeric conversions

0 commit comments

Comments
 (0)