Uploaded image for project: 'Commons Imaging'
  1. Commons Imaging
  2. IMAGING-211

Imaging.getBufferedImage fails throwing java.lang.ArrayIndexOutOfBoundsException for specific inputs -- evintila-april_dynamics

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-alpha1
    • 1.0-alpha2
    • Format: PNG
    • Ubuntu 17.10

    • Patch, Important

    Description

      For specific inputs, Imaging.getBufferedImage fails throwing java.lang.ArrayIndexOutOfBoundsException: -99, instead of ImageReadException or IOException.
      Example code that can be used to reproduce the problem, with "testfile_2" found at this link testfile_2:

      // evintila @ April Dynamics
      File file = new File("testfile_2");
      final Map<String, Object> params = new HashMap<>();
      params.put(ImagingConstants.BUFFERED_IMAGE_FACTORY,
      new ManagedImageBufferedImageFactory());
      
      try
      
      { // the problem is here: 
          final BufferedImage image = Imaging.getBufferedImage(file, params); }
      
      catch (ImageReadException e)
      {
      
      } catch (IOException e)
      {
      
      }

      Output:

      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -99
      at org.apache.commons.imaging.formats.png.chunks.PngChunkIhdr.<init>(PngChunkIhdr.java:55)
      at org.apache.commons.imaging.formats.png.PngImageParser.readChunks(PngImageParser.java:186)
      at org.apache.commons.imaging.formats.png.PngImageParser.readChunks(PngImageParser.java:229)
      at org.apache.commons.imaging.formats.png.PngImageParser.getBufferedImage(PngImageParser.java:494)
      at org.apache.commons.imaging.Imaging.getBufferedImage(Imaging.java:1377)
      at org.apache.commons.imaging.Imaging.getBufferedImage(Imaging.java:1365)

       

      Attachments

        1. testfile_2.png
          34 kB
          Bruno P. Kinoshita

        Issue Links

          Activity

            People

              kinow Bruno P. Kinoshita
              evintila-april_dynamics Emanuel Vintila
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m