Merge pull request #11301 from Snuffleupagus/peekByte-eof

Ensure that the `peekByte` methods, on the various Streams, handles end of data correctly (PR 5286 follow-up)
This commit is contained in:
Tim van der Meij 2019-11-01 22:42:34 +01:00 committed by GitHub
commit 0eda75c8fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -213,7 +213,9 @@ class ChunkedStream {
peekByte() {
const peekedByte = this.getByte();
this.pos--;
if (peekedByte !== -1) {
this.pos--;
}
return peekedByte;
}

View File

@ -86,7 +86,9 @@ var Stream = (function StreamClosure() {
},
peekByte: function Stream_peekByte() {
var peekedByte = this.getByte();
this.pos--;
if (peekedByte !== -1) {
this.pos--;
}
return peekedByte;
},
peekBytes(length, forceClamped = false) {
@ -234,7 +236,9 @@ var DecodeStream = (function DecodeStreamClosure() {
},
peekByte: function DecodeStream_peekByte() {
var peekedByte = this.getByte();
this.pos--;
if (peekedByte !== -1) {
this.pos--;
}
return peekedByte;
},
peekBytes(length, forceClamped = false) {