diff --git a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java index 7deb6f22a6..bd9ee097ef 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java @@ -22,7 +22,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -63,6 +62,20 @@ class TestXWPFPictureData { } } + @Test + void testReadMaxSize() throws InvalidFormatException, IOException { + int prev = XWPFPictureData.getMaxImageSize(); + try { + // check for a regression in 5.2.1: + // even if we set the maximum to a very high value it should not + // simply allocate that much here + XWPFPictureData.setMaxImageSize(Integer.MAX_VALUE-1); + testRead(); + } finally { + XWPFPictureData.setMaxImageSize(prev); + } + } + @Test void testPictureInHeader() throws IOException { try (XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("headerPic.docx")) {