This is an automated email from the ASF dual-hosted git repository. centic pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/poi.git
commit e9e9612a1f19a0e88e68ece7b3b0527954a887d9 Author: Dominik Stadler <[email protected]> AuthorDate: Thu Feb 19 21:56:06 2026 +0100 Avoid ClassCastException when reading headers of EMF files --- .../org/apache/poi/hemf/usermodel/HemfPicture.java | 2 ++ .../slideshow/VHZ2NYFUYUUJNGLABL26ORTQZA76FJEW.emf | Bin 0 -> 135092 bytes test-data/spreadsheet/stress.xls | Bin 80384 -> 80384 bytes 3 files changed, 2 insertions(+) diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfPicture.java b/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfPicture.java index ffd51c65c4..95d73082b8 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfPicture.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hemf/usermodel/HemfPicture.java @@ -81,6 +81,8 @@ public class HemfPicture implements Iterable<HemfRecord>, GenericRecord { List<HemfRecord> r = getRecords(); if (r.isEmpty()) { throw new RecordFormatException("No records could be parsed - your .emf file is invalid"); + } else if (!(r.get(0) instanceof HemfHeader)) { + throw new RecordFormatException("Could not convert object of type " + r.get(0).getClass() + " + - your .emf file is invalid"); } else { return (HemfHeader)r.get(0); } diff --git a/test-data/slideshow/VHZ2NYFUYUUJNGLABL26ORTQZA76FJEW.emf b/test-data/slideshow/VHZ2NYFUYUUJNGLABL26ORTQZA76FJEW.emf new file mode 100755 index 0000000000..6dac267f33 Binary files /dev/null and b/test-data/slideshow/VHZ2NYFUYUUJNGLABL26ORTQZA76FJEW.emf differ diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index b0f95e64b3..aec4cdf62e 100644 Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
