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 2024/11/27 17:10:36 UTC

svn commit: r1922177 - /pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java

Author: tilman
Date: Wed Nov 27 17:10:36 2024
New Revision: 1922177

URL: http://svn.apache.org/viewvc?rev=1922177&view=rev
Log:
PDFBOX-5908: improve / simplify / clarify code as suggested by Michael Klink

Modified:
    pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java

Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java?rev=1922177&r1=1922176&r2=1922177&view=diff
==============================================================================
--- pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java (original)
+++ pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java Wed Nov 27 17:10:36 2024
@@ -270,13 +270,13 @@ public abstract class Filter
             }
             // we don't know the size of the decoded stream, just estimate a 4 times bigger size than the encoded stream
             // use the estimated stream size as chunk size, use the default chunk size as limit to avoid to big values
-            if (length >= RandomAccessReadBuffer.DEFAULT_CHUNK_SIZE_4KB / 4)
+            if (length <= 0 || length >= RandomAccessReadBuffer.DEFAULT_CHUNK_SIZE_4KB / 4)
             {
                 length = RandomAccessReadBuffer.DEFAULT_CHUNK_SIZE_4KB;
             }
             else
             {
-                length = Math.min(length << 2, RandomAccessReadBuffer.DEFAULT_CHUNK_SIZE_4KB);
+                length = length * 4;
             }
             randomAccessWriteBuffer = new RandomAccessReadWriteBuffer((int) length);
             output = new RandomAccessOutputStream(randomAccessWriteBuffer);