From 8847f5a96256c18d1728e91816019ea883749140 Mon Sep 17 00:00:00 2001 From: Maxim Date: Fri, 13 Dec 2024 12:46:21 +0300 Subject: [PATCH] Fix COSPredictorDecode --- .../verapdf/cos/filters/COSPredictorDecode.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/verapdf/cos/filters/COSPredictorDecode.java b/src/main/java/org/verapdf/cos/filters/COSPredictorDecode.java index 97fcb1f0..96d670bc 100644 --- a/src/main/java/org/verapdf/cos/filters/COSPredictorDecode.java +++ b/src/main/java/org/verapdf/cos/filters/COSPredictorDecode.java @@ -116,19 +116,19 @@ public int read(byte[] buffer, int size) throws IOException { linePredictor += 10; } - int read; - if ((read = bufferPopArray(currentLine, lineLength)) != lineLength) { + int read = bufferPopArray(currentLine, lineLength); + while (read != lineLength) { if (this.feedBuffer(this.getBufferCapacity()) == -1) { this.streamEnded = true; break; } byte[] extraBytes = new byte[lineLength - read]; - int readAgain; - if ((readAgain = bufferPopArray(extraBytes, extraBytes.length)) != extraBytes.length) { - this.streamEnded = true; - break; - } + int readAgain = bufferPopArray(extraBytes, extraBytes.length); System.arraycopy(extraBytes, 0, currentLine, read, readAgain); + read += readAgain; + } + if (streamEnded) { + break; } switch (linePredictor) {