pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1814226 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/RunLengthDecodeFilter.java
Date Fri, 03 Nov 2017 17:06:34 GMT
Author: lehmi
Date: Fri Nov  3 17:06:34 2017
New Revision: 1814226

URL: http://svn.apache.org/viewvc?rev=1814226&view=rev
Log:
PDFBOX-3990: detect EOF while decompressing

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/RunLengthDecodeFilter.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/RunLengthDecodeFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/RunLengthDecodeFilter.java?rev=1814226&r1=1814225&r2=1814226&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/RunLengthDecodeFilter.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/filter/RunLengthDecodeFilter.java
Fri Nov  3 17:06:34 2017
@@ -45,10 +45,15 @@ final class RunLengthDecodeFilter extend
             if (dupAmount <= 127)
             {
                 int amountToCopy = dupAmount + 1;
-                int compressedRead;
+                int compressedRead = 0;
                 while(amountToCopy > 0)
                 {
                     compressedRead = encoded.read(buffer, 0, amountToCopy);
+                    // EOF reached?
+                    if (compressedRead == -1)
+                    {
+                        break;
+                    }
                     decoded.write(buffer, 0, compressedRead);
                     amountToCopy -= compressedRead;
                 }



Mime
View raw message