mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-04-30 00:00:01 -04:00
TMI-120: Fix IIOOBE when file has no image. Will throw exceptions when trying to read or get metadata.
This commit is contained in:
+16
@@ -1360,6 +1360,22 @@ public class JPEGImageReaderTest extends ImageReaderAbstractTestCase<JPEGImageRe
|
||||
return sortedNodes;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNumImagesBogusDataPrepended() throws IOException {
|
||||
// The JPEGImageReader (incorrectly) interprets this image to be a "tables only" image.
|
||||
|
||||
JPEGImageReader reader = createReader();
|
||||
|
||||
try {
|
||||
reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/broken-jpeg/broken-bogus-data-prepended-real-jfif-start-at-4801.jpg")));
|
||||
assertEquals(-1, reader.getNumImages(false)); // Ok
|
||||
assertEquals(0, reader.getNumImages(true)); // Should throw IIOException or return 0
|
||||
}
|
||||
finally {
|
||||
reader.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNegativeSOSComponentCount() throws IOException {
|
||||
// The data in the stream looks like this:
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 530 KiB |
Reference in New Issue
Block a user