Skip to content

Commit

Permalink
Merge pull request #11301 from Snuffleupagus/peekByte-eof
Browse files Browse the repository at this point in the history
Ensure that the `peekByte` methods, on the various Streams, handles end of data correctly (PR 5286 follow-up)
  • Loading branch information
timvandermeij authored Nov 1, 2019
2 parents 30ef05c + 829d6ba commit 0eda75c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/core/chunked_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ class ChunkedStream {

peekByte() {
const peekedByte = this.getByte();
this.pos--;
if (peekedByte !== -1) {
this.pos--;
}
return peekedByte;
}

Expand Down
8 changes: 6 additions & 2 deletions src/core/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 0eda75c

Please sign in to comment.