Skip to content

Commit

Permalink
PDFBOX-5908: improve / simplify / clarify code as suggested by Michae…
Browse files Browse the repository at this point in the history
…l Klink

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922178 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Nov 27, 2024
1 parent 9a946bd commit 3007890
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pdfbox/src/main/java/org/apache/pdfbox/filter/Filter.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ public static RandomAccessRead decode(InputStream encoded, List<Filter> filterLi
}
// 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);
Expand Down

0 comments on commit 3007890

Please sign in to comment.