From 2258b4def265da585e67f4034e2b2277641474b4 Mon Sep 17 00:00:00 2001 From: Oliver Schmidtmer Date: Wed, 17 Feb 2016 15:08:06 +0100 Subject: [PATCH] More tolerant CCITT reading if the stream contains less lines than are tried to read --- .../imageio/plugins/tiff/CCITTFaxDecoderStream.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStream.java b/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStream.java index d22821c7..2094c14a 100644 --- a/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStream.java +++ b/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStream.java @@ -34,6 +34,7 @@ import java.io.EOFException; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Arrays; /** * CCITT Modified Huffman RLE, Group 3 (T4) and Group 4 (T6) fax compression. @@ -403,14 +404,14 @@ final class CCITTFaxDecoderStream extends FilterInputStream { @Override public int read() throws IOException { if (decodedLength < 0) { - return -1; + return 0xFF; } if (decodedPos >= decodedLength) { fetch(); if (decodedLength < 0) { - return -1; + return 0xFF; } } @@ -420,14 +421,16 @@ final class CCITTFaxDecoderStream extends FilterInputStream { @Override public int read(byte[] b, int off, int len) throws IOException { if (decodedLength < 0) { - return -1; + Arrays.fill(b, off, len, (byte)0xFF); + return len; } if (decodedPos >= decodedLength) { fetch(); if (decodedLength < 0) { - return -1; + Arrays.fill(b, off, len, (byte)0xFF); + return len; } }