Skip to content

Commit

Permalink
disallow NaN, Infinity and -Infinity values
Browse files Browse the repository at this point in the history
  • Loading branch information
Revxrsal committed Oct 19, 2024
1 parent ff8b130 commit e468037
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ public void extend(@NotNull String str) {
public float readFloat() {
String value = readUnquotedString();
try {
return Float.parseFloat(value);
float v = Float.parseFloat(value);
if (Float.isFinite(v)) return v;
throw new InvalidDecimalException(value);
} catch (NumberFormatException e) {
throw new InvalidDecimalException(value);
}
Expand All @@ -142,7 +144,9 @@ public float readFloat() {
public double readDouble() {
String value = readUnquotedString();
try {
return Double.parseDouble(value);
double v = Double.parseDouble(value);
if (Double.isFinite(v)) return v;
throw new InvalidDecimalException(value);
} catch (NumberFormatException e) {
throw new InvalidDecimalException(value);
}
Expand Down

0 comments on commit e468037

Please sign in to comment.