Skip to content

Commit

Permalink
Merge pull request mozilla#7670 from Snuffleupagus/Parser_makeFilter-…
Browse files Browse the repository at this point in the history
…maybeLength

Only skip parsing a stream in `Parser_makeFilter` when we know for sure that it is empty (PR 6372 follow-up)
  • Loading branch information
yurydelendik committed Oct 5, 2016
2 parents b4a9012 + a22f0ae commit 7b2a9ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,10 @@ var Parser = (function ParserClosure() {
return stream;
},
makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
if (stream.dict.get('Length') === 0 && !maybeLength) {
// Since the 'Length' entry in the stream dictionary can be completely
// wrong, e.g. zero for non-empty streams, only skip parsing the stream
// when we can be absolutely certain that it actually is empty.
if (maybeLength === 0) {
warn('Empty "' + name + '" stream.');
return new NullStream(stream);
}
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
!simpletype3font.pdf
!sizes.pdf
!javauninstall-7r.pdf
!multiple-filters-length-zero.pdf
!issue3205r.pdf
!issue3207r.pdf
!issue3263r.pdf
Expand Down
Binary file added test/pdfs/multiple-filters-length-zero.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,13 @@
"lastPage": 1,
"type": "eq"
},
{ "id": "multiple-filters-length-zero",
"file": "pdfs/multiple-filters-length-zero.pdf",
"md5": "c273c3a6fb79cbf3034fe1b62b204728",
"rounds": 1,
"link": false,
"type": "eq"
},
{ "id": "issue5752",
"file": "pdfs/issue5752.pdf",
"md5": "aa20ad7cff71e9481c0cd623ddbff3b7",
Expand Down

0 comments on commit 7b2a9ee

Please sign in to comment.