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

sanselan throws a java.lang.NegativeArraySizeException on at least this one .jpg file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.97
    • 1.0-alpha1
    • Format: JPEG
    • None
    • Linux, Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
      (though I doubt that matters.)

    Description

      Saneslan seems unable to run getImageInfo() on the attached file, gives this error –

      java.lang.NegativeArraySizeException
      at org.apache.sanselan.common.BinaryFileFunctions.readByteArray(BinaryFileFunctions.java:496)
      at org.apache.sanselan.formats.jpeg.JpegUtils.traverseJFIF(JpegUtils.java:94)
      at org.apache.sanselan.formats.jpeg.JpegImageParser.readSegments(JpegImageParser.java:170)
      at org.apache.sanselan.formats.jpeg.JpegImageParser.readSegments(JpegImageParser.java:267)
      at org.apache.sanselan.formats.jpeg.JpegImageParser.getImageInfo(JpegImageParser.java:659)
      at org.apache.sanselan.Sanselan.getImageInfo(Sanselan.java:589)
      at org.apache.sanselan.Sanselan.getImageInfo(Sanselan.java:563)
      at org.apache.sanselan.Sanselan.getImageInfo(Sanselan.java:582)
      at SanselanTest.main(SanselanTest.java:68)

      Now, this error seems very similar to IMAGING-21, but it's not quite the same for two reasons –

      1) the stack is somewhat different, and
      2) the fix provided for that bug does not fix this issue.

      Now, looking at the file that triggers this issue, other tools throw a warning for it –

      gimp says: Corrupt JPEG data: 2715 extraneous bytes before marker 0xe2
      xv says the same thing.
      convert from ImageMagick converts it with no error or warning.
      jhead says: Nonfatal Error : 'pod_tile_foundation.jpg' Extraneous 2715 padding bytes before section E2
      jpegtran says: Corrupt JPEG data: 2715 extraneous bytes before marker 0xe2

      ... so it seems there's something actually wrong with this file, but even so, the image is there, and other tools can determine the dimensions of it, so in theory sanselan ought to be able to as well.

      I'll include the somewhat corrupt file that is triggering this exception, as well as the test case program (which came straight from IMAGING-21.)

      The test case also checks the two files that were included in IMAGING-21 just to show that that problem was fixed (at least once I applied the fix included there.)

      Attachments

        1. SanselanTest.java
          3 kB
          Doug McLaren
        2. pod_tile_foundation.jpg
          76 kB
          Doug McLaren

        Activity

          People

            Unassigned Unassigned
            dougmc Doug McLaren
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: