Don't allow non-finite doubles and floats

This commit is contained in:
Magnus Ulf 2018-12-22 01:00:53 +01:00
parent 81519542e8
commit 3627d7e88f
2 changed files with 6 additions and 2 deletions

View File

@ -25,7 +25,9 @@ public class TypeDouble extends TypeAbstractNumber<Double>
@Override
public Double valueOf(String arg, CommandSender sender) throws Exception
{
return Double.parseDouble(arg);
var ret = Double.parseDouble(arg);
if (!Double.isFinite(ret)) throw new Exception();
return ret;
}
}

View File

@ -25,7 +25,9 @@ public class TypeFloat extends TypeAbstractNumber<Float>
@Override
public Float valueOf(String arg, CommandSender sender) throws Exception
{
return Float.parseFloat(arg);
var ret = Float.parseFloat(arg);
if (!Float.isFinite(ret)) throw new Exception();
return ret;
}
}