Avoid NPE with malformed wmf headers

This commit is contained in:
Dominik Stadler 2026-02-14 20:04:58 +01:00
parent 692caf0f36
commit bc02ef0703
3 changed files with 12 additions and 2 deletions

View File

@ -511,8 +511,18 @@ public class HwmfMisc {
@Override @Override
public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException { public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException {
style = HwmfBrushStyle.valueOf(leis.readUShort()); int brushStyle = leis.readUShort();
colorUsage = ColorUsage.valueOf(leis.readUShort()); style = HwmfBrushStyle.valueOf(brushStyle);
if (style == null) {
throw new IllegalArgumentException("Could not read brush-style " + brushStyle);
}
int colorUsageEnum = leis.readUShort();
colorUsage = ColorUsage.valueOf(colorUsageEnum);
if (colorUsage == null) {
throw new IllegalArgumentException("Could not read color-usage " + colorUsage);
}
int size = 2*LittleEndianConsts.SHORT_SIZE; int size = 2*LittleEndianConsts.SHORT_SIZE;
switch (style) { switch (style) {
case BS_SOLID: case BS_SOLID:

Binary file not shown.