mirror of https://github.com/apache/poi.git
Bug 66425: Avoid exceptions found via poi-fuzz
Prevent ClassCastException Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=63375 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1914990 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8e3b60f63d
commit
28811d26df
|
@ -44,7 +44,7 @@ import org.apache.poi.ss.formula.eval.NotImplementedException;
|
|||
@SuppressWarnings("serial")
|
||||
public class FractionFormat extends Format {
|
||||
private static final Logger LOGGER = LogManager.getLogger(FractionFormat.class);
|
||||
private static final Pattern DENOM_FORMAT_PATTERN = Pattern.compile("(?:(#+)|(\\d+))");
|
||||
private static final Pattern DENOM_FORMAT_PATTERN = Pattern.compile("(#+)|(\\d+)");
|
||||
|
||||
//this was chosen to match the earlier limitation of max denom power
|
||||
//it can be expanded to get closer to Excel's calculations
|
||||
|
@ -189,6 +189,10 @@ public class FractionFormat extends Format {
|
|||
|
||||
@Override
|
||||
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
|
||||
if (!(obj instanceof Number)) {
|
||||
throw new IllegalArgumentException("Cannot format object of " + obj.getClass() + " to number: " + obj);
|
||||
}
|
||||
|
||||
return toAppendTo.append(format((Number)obj));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue