diff --git a/src/core/flate_stream.js b/src/core/flate_stream.js index e660f39db..f1753d01b 100644 --- a/src/core/flate_stream.js +++ b/src/core/flate_stream.js @@ -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; } diff --git a/test/pdfs/issue18298.pdf.link b/test/pdfs/issue18298.pdf.link new file mode 100644 index 000000000..afaf55127 --- /dev/null +++ b/test/pdfs/issue18298.pdf.link @@ -0,0 +1 @@ +https://github.com/user-attachments/files/15908428/example-malformed.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 98eb53829..a1b849853 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -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",