Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8211795

ArrayIndexOutOfBoundsException in PNGImageReader after JDK-6788458

XMLWordPrintable

        The fix for JDK-6788458 causes PNGImageReader to throw an ArrayIndexOutOfBoundsException reading some pngs that it previously accepted.

        ===
        import javax.imageio.ImageIO;
        import java.awt.image.BufferedImage;
        import java.io.File;
        import java.io.IOException;

        public class Image {
          public static void main(String[] args) throws IOException {
            BufferedImage image = ImageIO.read(new File(args[0]));
            ImageIO.write(image, "PNG", new File(args[1]));
          }
        }
        ===

        $ javac image.java
        $ java Image add_white.png output.png
        ...
        Exception in thread "main" javax.imageio.IIOException: Caught exception during read:
        at java.desktop/com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1817)
        at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1468)
        at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1315)
        at Image.main(Image.java:8)
        Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
        at java.desktop/com.sun.imageio.plugins.png.PNGImageReader.decodePass(PNGImageReader.java:1308)
        at java.desktop/com.sun.imageio.plugins.png.PNGImageReader.decodeImage(PNGImageReader.java:1360)
        at java.desktop/com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1493)
        at java.desktop/com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1810)
        ... 3 more

              jdv Jayathirth D V
              cushon Liam Miller-Cushon
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: