diff --git a/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java b/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java index acebed22dc..249e74cb2e 100644 --- a/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java +++ b/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java @@ -61,7 +61,7 @@ public class DefaultEscherRecordFactory implements EscherRecordFactory { return EscherContainerRecord::new; } - if (recordTypes.constructor != null) { + if (recordTypes.constructor != null && recordTypes != EscherRecordTypes.UNKNOWN) { return recordTypes.constructor; } diff --git a/src/java/org/apache/poi/ddf/EscherBitmapBlip.java b/src/java/org/apache/poi/ddf/EscherBitmapBlip.java index 6fa056b8cd..f6d8aea45a 100644 --- a/src/java/org/apache/poi/ddf/EscherBitmapBlip.java +++ b/src/java/org/apache/poi/ddf/EscherBitmapBlip.java @@ -74,7 +74,7 @@ public class EscherBitmapBlip extends EscherBlipRecord { @Override public int getRecordSize() { - return 8 + 16 + 1 + getPicturedata().length; + return 8 + 16 + 1 + (getPicturedata() == null ? 0 : getPicturedata().length); } /** diff --git a/src/java/org/apache/poi/ddf/EscherRecordTypes.java b/src/java/org/apache/poi/ddf/EscherRecordTypes.java index 53afd2f2b8..150bb4300b 100644 --- a/src/java/org/apache/poi/ddf/EscherRecordTypes.java +++ b/src/java/org/apache/poi/ddf/EscherRecordTypes.java @@ -50,12 +50,12 @@ public enum EscherRecordTypes { CLSID(0xf016, null, null, null), CALLOUT_RULE(0xf017, null, null, null), BLIP_START(0xf018, "Blip", "msofbtBlip", null), - BLIP_EMF(0xf018 + 2, "BlipEmf", null, EscherMetafileBlip::new), - BLIP_WMF(0xf018 + 3, "BlipWmf", null, EscherMetafileBlip::new), - BLIP_PICT(0xf018 + 4, "BlipPict", null, EscherMetafileBlip::new), - BLIP_JPEG(0xf018 + 5, "BlipJpeg", null, EscherBitmapBlip::new), - BLIP_PNG(0xf018 + 6, "BlipPng", null, EscherBitmapBlip::new), - BLIP_DIB(0xf018 + 7, "BlipDib", null, EscherBitmapBlip::new), + BLIP_EMF(0xf018 + 2 /* 0xf01a */, "BlipEmf", null, EscherMetafileBlip::new), + BLIP_WMF(0xf018 + 3 /* 0xf01b */, "BlipWmf", null, EscherMetafileBlip::new), + BLIP_PICT(0xf018 + 4 /* 0xf01c */, "BlipPict", null, EscherMetafileBlip::new), + BLIP_JPEG(0xf018 + 5 /* 0xf01d */, "BlipJpeg", null, EscherBitmapBlip::new), + BLIP_PNG(0xf018 + 6 /* 0xf01e */, "BlipPng", null, EscherBitmapBlip::new), + BLIP_DIB(0xf018 + 7 /* 0xf01f */, "BlipDib", null, EscherBitmapBlip::new), BLIP_END(0xf117, "Blip", "msofbtBlip", null), REGROUP_ITEMS(0xf118, null, null, null), SELECTION(0xf119, null, null, null), diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java index 89198d2758..035e7f0bb0 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java @@ -892,4 +892,14 @@ public class TestBugs{ assertNotNull(document); } } + + @Test + public void test64132() throws IOException { + try(HWPFDocument doc = HWPFTestDataSamples.openSampleFile("64132.doc")) { + assertNotNull(doc); + PicturesTable picturesTable = doc.getPicturesTable(); + List pictures = picturesTable.getAllPictures(); + assertNotNull(pictures); + } + } } diff --git a/test-data/document/64132.doc b/test-data/document/64132.doc new file mode 100644 index 0000000000..6cce0349ce Binary files /dev/null and b/test-data/document/64132.doc differ