You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2014/04/29 07:41:17 UTC

svn commit: r1590873 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java

Author: tilman
Date: Tue Apr 29 05:41:17 2014
New Revision: 1590873

URL: http://svn.apache.org/r1590873
Log:
PDFBOX-2048: handle stream that incorrectly claims to have length 0

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java?rev=1590873&r1=1590872&r2=1590873&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSStream.java Tue Apr 29 05:41:17 2014
@@ -311,7 +311,7 @@ public class COSStream extends COSDictio
         // in case we need it later
         long writtenLength = unFilteredStream.getLengthWritten();  
 
-        if( length == 0 )
+        if (length == 0 && writtenLength == 0)
         {
             //if the length is zero then don't bother trying to decode
             //some filters don't work when attempting to decode
@@ -325,7 +325,7 @@ public class COSStream extends COSDictio
             //ok this is a simple hack, sometimes we read a couple extra
             //bytes that shouldn't be there, so we encounter an error we will just
             //try again with one less byte.
-            for( int tryCount=0; !done && tryCount<5; tryCount++ )
+            for (int tryCount = 0; length > 0 && !done && tryCount < 5; tryCount++)
             {
                 InputStream input = null;
                 try