Avoid ClassCastException when reading headers of EMF files

This commit is contained in:
Dominik Stadler 2026-02-19 21:56:06 +01:00
parent 1594baf696
commit e9e9612a1f
3 changed files with 2 additions and 0 deletions

View File

@ -81,6 +81,8 @@ public class HemfPicture implements Iterable<HemfRecord>, GenericRecord {
List<HemfRecord> r = getRecords(); List<HemfRecord> r = getRecords();
if (r.isEmpty()) { if (r.isEmpty()) {
throw new RecordFormatException("No records could be parsed - your .emf file is invalid"); 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 { } else {
return (HemfHeader)r.get(0); return (HemfHeader)r.get(0);
} }

Binary file not shown.

Binary file not shown.