mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Ensure that the peekByte
methods, on the various Streams, handles end of data correctly (PR 5286 follow-up)
When the end of data has already been reached for the various Streams, the `getByte` methods will return `-1` to signal that to the caller. Note however that the current position obviously won't be incremented in this case, meaning that the `peekByte` methods will in this case *incorrectly* decrement the position. Thankfully the corresponding `peekBytes` shouldn't be affected by this bug, since they decrement the current position with the *actually* returned number of bytes. I'm not aware of any bugs caused by this blatant oversight, but that doesn't mean this shouldn't be fixed :-)
This commit is contained in:
parent
30ef05c161
commit
829d6ba2dc
2 changed files with 9 additions and 3 deletions
|
@ -213,7 +213,9 @@ class ChunkedStream {
|
|||
|
||||
peekByte() {
|
||||
const peekedByte = this.getByte();
|
||||
this.pos--;
|
||||
if (peekedByte !== -1) {
|
||||
this.pos--;
|
||||
}
|
||||
return peekedByte;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue