diff --git a/src/core/stream.js b/src/core/stream.js index 35dc4fbdb..7567081c9 100644 --- a/src/core/stream.js +++ b/src/core/stream.js @@ -508,12 +508,18 @@ var FlateStream = (function FlateStreamClosure() { var buffer = this.ensureBuffer(bufferLength + blockLen); var end = bufferLength + blockLen; this.bufferLength = end; - for (var n = bufferLength; n < end; ++n) { - if (typeof (b = bytes[bytesPos++]) == 'undefined') { + if (blockLen === 0) { + if (typeof bytes[bytesPos] == 'undefined') { this.eof = true; - break; } - buffer[n] = b; + } else { + for (var n = bufferLength; n < end; ++n) { + if (typeof (b = bytes[bytesPos++]) == 'undefined') { + this.eof = true; + break; + } + buffer[n] = b; + } } this.bytesPos = bytesPos; return; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 76685349d..24268df1d 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -62,3 +62,4 @@ !issue3371.pdf !issue2956.pdf !bug946506.pdf +!issue3885.pdf diff --git a/test/pdfs/issue3885.pdf b/test/pdfs/issue3885.pdf new file mode 100644 index 000000000..183294ccf Binary files /dev/null and b/test/pdfs/issue3885.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 3bec7f41a..ea20da375 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -61,6 +61,14 @@ "lastPage": 2, "type": "eq" }, + { "id": "issue3885", + "file": "pdfs/issue3885.pdf", + "md5": "319c998910453bc44d40c7748cd2cb79", + "rounds": 1, + "firstPage": 1, + "lastPage": 1, + "type": "eq" + }, { "id": "issue2833", "file": "pdfs/issue2833.pdf", "md5": "7bc6e17c41586155c188d7408bcb9ab5",