Skip to content

Commit 3007890

Browse files
committed
PDFBOX-5908: improve / simplify / clarify code as suggested by Michael Klink
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922178 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9a946bd commit 3007890

File tree

1 file changed

+2
-2
lines changed
  • pdfbox/src/main/java/org/apache/pdfbox/filter

1 file changed

+2
-2
lines changed

pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,13 @@ public static RandomAccessRead decode(InputStream encoded, List<Filter> filterLi
270270
}
271271
// we don't know the size of the decoded stream, just estimate a 4 times bigger size than the encoded stream
272272
// use the estimated stream size as chunk size, use the default chunk size as limit to avoid to big values
273-
if (length >= RandomAccessReadBuffer.DEFAULT_CHUNK_SIZE_4KB / 4)
273+
if (length <= 0 || length >= RandomAccessReadBuffer.DEFAULT_CHUNK_SIZE_4KB / 4)
274274
{
275275
length = RandomAccessReadBuffer.DEFAULT_CHUNK_SIZE_4KB;
276276
}
277277
else
278278
{
279-
length = Math.min(length << 2, RandomAccessReadBuffer.DEFAULT_CHUNK_SIZE_4KB);
279+
length = length * 4;
280280
}
281281
randomAccessWriteBuffer = new RandomAccessReadWriteBuffer((int) length);
282282
output = new RandomAccessOutputStream(randomAccessWriteBuffer);

0 commit comments

Comments
 (0)