Fix a bug in the "getChunkOfStream" function

This commit is contained in:
Maschell 2019-04-07 14:53:35 +02:00
parent 31fcc4fc6d
commit 7bd424ec42

View File

@ -88,8 +88,17 @@ public final class StreamUtils {
System.arraycopy(overflowbuf, 0, output, inBlockBuffer, toRead);
inBlockBuffer += toRead;
if (tooMuch > 0) {
System.arraycopy(overflowbuf, toRead, overflowbuf, 0, tooMuch);
overflowbuffer.setLengthOfDataInBuffer(tooMuch);
} else {
// Moving into front.
int missingLength = overflowbuffer.getLengthOfDataInBuffer() - toRead;
if (missingLength > 0) {
System.arraycopy(overflowbuf, toRead, overflowbuf, 0, missingLength);
overflowbuffer.setLengthOfDataInBuffer(missingLength);
}
}
} else {
System.arraycopy(overflowbuf, 0, output, inBlockBuffer, overflowbuffer.getLengthOfDataInBuffer());
inBlockBuffer += overflowbuffer.getLengthOfDataInBuffer();