Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
There is a missing check in the NumberUtils.getMantissa(String, Integer) method where a possible IndexOutOfBoundsException could be thrown when invalid str and stopPos are given.
private static String getMantissa(final String str, final int stopPos) { final char firstChar = str.charAt(0); final boolean hasSign = firstChar == '-' || firstChar == '+'; return hasSign ? str.substring(1, stopPos) : str.substring(0, stopPos); }
When getMantissa("-", 0); is called, the substring method throws IndexOutOfBoundsException. This could happen when calling the public NumberUtils.createNumber("-");.
A checking can be added to the method and throw NumberFormatException when the number is invalid.
Attachments
Issue Links
- links to