pdf.js/src
Rob Wu 43847d7ff8 Set eof to true at the end of a FlateStream
At the initialization of `Lexer_getObj` (in `parser.js`), there's a loop
that skips whitespace and breaks out whenever EOF is encountered.
(88ec2bd1a/src/core/parser.js (L586-L599))

Whenever the current character is not a whitespace character,
`ch = this.nextChar();` is used to find the next character
(using `return this.currentChar = this.stream.getByte())`).

The aforementioned `getByte` method retrieves the next byte using
(88ec2bd1a/src/core/stream.js (L122-L128))

      var pos = this.pos;
      while (this.bufferLength <= pos) {
        if (this.eof)
          return -1;
        this.readBlock();
      }
      return this.buffer[this.pos++];

This piece of code relies on this.eof to detect whether the last character
has been read. When the stream is a `FlateStream`, and the end of the stream
has been reached, then **`this.eof` is not set to `true`**, because this check
is done inside a loop that does not occur when the read block size is zero:
(88ec2bd1ac/src/core/stream.js (L511-L517))

      for (var n = bufferLength; n < end; ++n) {
        if (typeof (b = bytes[bytesPos++]) == 'undefined') {
          this.eof = true;
          break;
        }
        buffer[n] = b;
      }

This commit fixes the issue by setting this.eof to true whenever the loop is not
going to run (i.e. when bufferLength === end, i.e. blockLen === 0).
2013-12-19 18:37:39 +01:00
..
core Set eof to true at the end of a FlateStream 2013-12-19 18:37:39 +01:00
display Correct a typo in getJavaScript function expression name. 2013-12-16 21:40:43 +01:00
images Vectorize the logo. 2012-10-29 14:08:52 -04:00
shared Fix Blob creation in Safari 7.0. 2013-12-06 02:10:41 +13:00
pdf.js Specifies default workerSrc (if possible) 2013-08-16 11:33:54 -05:00
worker_loader.js Read multi-byte character codes based on codespace ranges. 2013-09-25 10:32:04 -07:00