Skip to content

Commit

Permalink
Merge pull request #18304 from Snuffleupagus/issue-18298
Browse files Browse the repository at this point in the history
Don't throw if there's not enough data to get the header in `FlateStream` (issue 18298)
  • Loading branch information
Snuffleupagus committed Jun 20, 2024
2 parents 9afd3a5 + 3fae2d7 commit e76242d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/flate_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,15 @@ class FlateStream extends DecodeStream {
}

readBlock() {
let buffer, len;
let buffer, hdr, len;
const str = this.str;
// read block header
let hdr = this.getBits(3);
try {
hdr = this.getBits(3);
} catch (ex) {
this.#endsStreamOnError(ex.message);
return;
}
if (hdr & 1) {
this.eof = true;
}
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue18298.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/user-attachments/files/15908428/example-malformed.pdf
9 changes: 9 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5438,6 +5438,15 @@
"lastPage": 1,
"type": "eq"
},
{
"id": "issue18298",
"file": "pdfs/issue18298.pdf",
"md5": "30a6108220c41ec88fa92ff45924a6cb",
"rounds": 1,
"link": true,
"lastPage": 1,
"type": "eq"
},
{
"id": "issue18138",
"file": "pdfs/issue18138.pdf",
Expand Down

0 comments on commit e76242d

Please sign in to comment.