< prev index next >
src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
Print this page
*** 734,743 ****
--- 734,754 ----
throw new IIOException("Invalid chunk length " + chunkLength);
}
switch (chunkType) {
case IDAT_TYPE:
+ /*
+ * PNG specification mandates that if colorType is
+ * PNG_COLOR_PALETTE then PLTE chunk should appear before
+ * the first IDAT chunk.
+ */
+ if (colorType == PNG_COLOR_PALETTE &&
+ metadata.PLTE_present == false)
+ {
+ throw new IIOException("PNG Header doesn't contain"
+ + " required PLTE chunk");
+ }
// If chunk type is 'IDAT', we've reached the image data.
if (imageStartPosition == -1L) {
/*
* PNGs may contain multiple IDAT chunks containing
* a portion of image data. We store the position of
< prev index next >