Commit b1f9798b by andrewlewis Committed by Oliver Woodman

Fix peeking the end of the stream then reading it.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=133240502
parent ab49425e
...@@ -125,7 +125,6 @@ public final class DefaultExtractorInput implements ExtractorInput { ...@@ -125,7 +125,6 @@ public final class DefaultExtractorInput implements ExtractorInput {
throws IOException, InterruptedException { throws IOException, InterruptedException {
ensureSpaceForPeek(length); ensureSpaceForPeek(length);
int bytesPeeked = Math.min(peekBufferLength - peekBufferPosition, length); int bytesPeeked = Math.min(peekBufferLength - peekBufferPosition, length);
peekBufferLength += length - bytesPeeked;
while (bytesPeeked < length) { while (bytesPeeked < length) {
bytesPeeked = readFromDataSource(peekBuffer, peekBufferPosition, length, bytesPeeked, bytesPeeked = readFromDataSource(peekBuffer, peekBufferPosition, length, bytesPeeked,
allowEndOfInput); allowEndOfInput);
...@@ -134,6 +133,7 @@ public final class DefaultExtractorInput implements ExtractorInput { ...@@ -134,6 +133,7 @@ public final class DefaultExtractorInput implements ExtractorInput {
} }
} }
peekBufferPosition += length; peekBufferPosition += length;
peekBufferLength = Math.max(peekBufferLength, peekBufferPosition);
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment