Skip to content

Commit

Permalink
Improve handling of JPEG images without an EOI marker (issue 12841)
Browse files Browse the repository at this point in the history
Given that the PDF document in the issue contains the same very large JPEG image *three* times, this patch includes a test-case where only the first page has been extracted from it.
  • Loading branch information
Snuffleupagus committed Jan 9, 2021
1 parent c0a6d6c commit 0749e65
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/jpg.js
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ var JpegImage = (function JpegImageClosure() {
offset = nextFileMarker.offset;
break;
}
if (offset >= data.length - 1) {
if (!nextFileMarker || offset >= data.length - 1) {
warn(
"JpegImage.parse - reached the end of the image data " +
"without finding an EOI marker (0xFFD9)."
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
!personwithdog.pdf
!helloworld-bad.pdf
!zerowidthline.pdf
!issue12841_reduced.pdf
!bug868745.pdf
!mmtype1.pdf
!issue4436r.pdf
Expand Down
Binary file added test/pdfs/issue12841_reduced.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3236,6 +3236,12 @@
"link": true,
"type": "eq"
},
{ "id": "issue12841",
"file": "pdfs/issue12841_reduced.pdf",
"md5": "5c645897c652853ad86b59df5fc6cce0",
"rounds": 1,
"type": "eq"
},
{ "id": "issue1597",
"file": "pdfs/issue1597.pdf",
"md5": "a5ebef467fd6e2fc0aeb56c9eb725ae3",
Expand Down

0 comments on commit 0749e65

Please sign in to comment.