diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java index 080938367b..0dc114ac67 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeFactory.java @@ -57,7 +57,11 @@ public class HSSFShapeFactory { } EscherClientDataRecord clientData = ((EscherContainerRecord) child).getChildById(EscherClientDataRecord.RECORD_ID); if (null != clientData) { - obj = (ObjRecord) agg.getShapeToObjMapping().get(clientData); + Record record = agg.getShapeToObjMapping().get(clientData); + if (!(record instanceof ObjRecord)) { + throw new IllegalArgumentException("Had unexpected type of clientData: " + (record == null ? "" : record.getClass())); + } + obj = (ObjRecord) record; } HSSFShapeGroup group = new HSSFShapeGroup(container, obj); List children = container.getChildContainers(); diff --git a/poi/src/test/java/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java b/poi/src/test/java/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java index b9abe815f4..f7af364978 100644 --- a/poi/src/test/java/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java +++ b/poi/src/test/java/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java @@ -57,6 +57,7 @@ class TestBiffDrawingToXml extends BaseTestIteratingXLS { excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5285517825277952.xls", IllegalArgumentException.class); excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5436547081830400.xls", IllegalArgumentException.class); excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5889658057523200.xls", IndexOutOfBoundsException.class); + excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls", IllegalArgumentException.class); return excludes; } diff --git a/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java b/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java index e21e359767..12854be920 100644 --- a/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java +++ b/poi/src/test/java/org/apache/poi/hssf/model/TestDrawingAggregate.java @@ -138,7 +138,9 @@ class TestDrawingAggregate { File[] files = testData.listFiles((dir, name) -> name.endsWith(".xls")); assertNotNull(files, "Need to find files in test-data path, had path: " + testData); return Stream.of(files). - filter(file -> !file.getName().equals("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5285517825277952.xls")). + filter(file -> + !file.getName().equals("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5285517825277952.xls") && + !file.getName().equals("clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls")). map(Arguments::of); } diff --git a/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls b/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls new file mode 100644 index 0000000000..2240cb1846 Binary files /dev/null and b/test-data/spreadsheet/clusterfuzz-testcase-minimized-POIHSSFFuzzer-4977868385681408.xls differ diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index 43e8f6950d..4a146faa1f 100644 Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ