LZWDecoder - IndexOutOfBoundsException when reading some files
See original GitHub issueWhen attempting to read and write certain grayscale tiffs, the following happens
- The resulting image is always corrupted
- Sometimes, an IndexOutOfBoundsException exception is raised when the LZWDecoder is is invoked via a call to com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader.read . This doesn’t always happen. I needed to run the test class a few times to see the exception.
Some files don’t have this issue, others do . See the code and test files for details
Thanks
Exception details
Exception in thread "main" java.lang.IndexOutOfBoundsException at java.nio.Buffer.checkIndex(Buffer.java:532) at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:172) at com.twelvemonkeys.imageio.plugins.tiff.LZWDecoder$LZWString.writeTo(LZWDecoder.java:330) at com.twelvemonkeys.imageio.plugins.tiff.LZWDecoder.decode(LZWDecoder.java:129) at com.twelvemonkeys.io.enc.DecoderStream.fill(DecoderStream.java:178) at com.twelvemonkeys.io.enc.DecoderStream.read(DecoderStream.java:122) at com.twelvemonkeys.io.LittleEndianDataInputStream.readFully(LittleEndianDataInputStream.java:423) at com.twelvemonkeys.io.LittleEndianDataInputStream.readFully(LittleEndianDataInputStream.java:396) at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader.readStripTileData(TIFFImageReader.java:1417) at com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader.read(TIFFImageReader.java:931) at javax.imageio.ImageIO.read(ImageIO.java:1448) at javax.imageio.ImageIO.read(ImageIO.java:1308) at ImagingIssue.main(ImagingIssue.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Thanks!
I need to look into this some more when I find the time, but it looks like there’s a problem with the LZW decoding.
Harald K
@balamuru This bugfix is now included in the official 3.3 release.