ImageIO PNG error on java 11

Jan Vomlel jan.vomlel at gmail.com
Fri Oct 12 09:33:45 UTC 2018


When I try to read some png files, I get exception:

     at 
java.desktop/com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:891)
     at 
java.desktop/com.sun.imageio.plugins.png.PNGImageReader.getImageMetadata(PNGImageReader.java:1799)
     Caused by: javax.imageio.IIOException: tEXt chunk length is not proper
     at 
java.desktop/com.sun.imageio.plugins.png.PNGImageReader.parse_tEXt_chunk(PNGImageReader.java:575)
     at 
java.desktop/com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:847)
     .. 28 more||

I think there are errors in file PNGImageReader. For example on line 574:
     if (textLength <= 0) {
         throw new IIOException("tEXt chunk length is not proper");
     }

Right condition is:
     if (textLength < 0) {
         throw new IIOException("tEXt chunk length is not proper");
     }
Similar problem is on a few other lines.

It was caused by commit:
http://hg.openjdk.java.net/jdk/jdk/rev/fb62f481671e

On java 10 it is working.

Bug can be tested on the image:
https://user-images.githubusercontent.com/12710508/46531012-fc1c4f80-c89b-11e8-91ec-65a81ae63f0f.png


<https://user-images.githubusercontent.com/12710508/46531012-fc1c4f80-c89b-11e8-91ec-65a81ae63f0f.png>


<https://user-images.githubusercontent.com/12710508/46531012-fc1c4f80-c89b-11e8-91ec-65a81ae63f0f.png>


<https://user-images.githubusercontent.com/12710508/46531012-fc1c4f80-c89b-11e8-91ec-65a81ae63f0f.png>



More information about the jdk-dev mailing list