mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
Avoid NPE with malformed wmf headers
This commit is contained in:
parent
692caf0f36
commit
bc02ef0703
@ -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.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user