JDK-4892630 : PNG Image Reader does not validate the image index passed to some of the methods
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-07-18
  • Updated: 2006-11-06
  • Resolved: 2005-11-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
6 b62Fixed
Related Reports
Relates :  
The API documentation for reader.getWidth(imgIndex), reader.getHeight(imgIndex), reader.getAspectRatio(imgIndex) claims that the above methods would throw an IndexOutOfBoundsException when the given image index is out of range. But this is not working for PNG ImageReader. PNG ImageReader returns the same width, height and aspect ratio regardless of what imageIndex is passed and the ImageIndex is not at all getting validated. This works fine for other readers such as GIF, JPEG and BMP. This gives an impression to the user that the image index specified by him exists in the input source even if it is out of range. This must be fixed and the exception must be thrown appropriately.

This is noticed since JDK1.4+ on Win32 as well as Solaris platforms.

I have attached a sample code. Execute the sample code as follows.
java ImageReaderTest <img file>
For Ex: java ImageReaderTest cup.png
If you don't see any exception, the bug is reproduced.

EVALUATION Simple fix; should try to get it in for RC.