diff --git a/src/core/chunked_stream.js b/src/core/chunked_stream.js index f58aa53bd..88663af8b 100644 --- a/src/core/chunked_stream.js +++ b/src/core/chunked_stream.js @@ -213,7 +213,9 @@ class ChunkedStream { peekByte() { const peekedByte = this.getByte(); - this.pos--; + if (peekedByte !== -1) { + this.pos--; + } return peekedByte; } diff --git a/src/core/stream.js b/src/core/stream.js index 1867c8c99..1b085a629 100644 --- a/src/core/stream.js +++ b/src/core/stream.js @@ -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) {