mirror of https://github.com/apache/poi.git
Add reproducer for possible OOM when reading pictures in XWPF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1899074 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d648c6d652
commit
306dc69105
|
@ -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")) {
|
||||
|
|
Loading…
Reference in New Issue