Don't render corrupted inlined images

Fixes #17794.
This commit is contained in:
Calixte Denizet 2024-03-14 21:23:26 +01:00
parent 30e69956db
commit 9c3471dd01
3 changed files with 40 additions and 21 deletions

View file

@ -739,6 +739,7 @@ class PartialEvaluator {
!dict.has("Mask") && !dict.has("Mask") &&
w + h < SMALL_IMAGE_DIMENSIONS w + h < SMALL_IMAGE_DIMENSIONS
) { ) {
try {
const imageObj = new PDFImage({ const imageObj = new PDFImage({
xref: this.xref, xref: this.xref,
res: resources, res: resources,
@ -760,6 +761,14 @@ class PartialEvaluator {
[imgData], [imgData],
optionalContent optionalContent
); );
} catch (reason) {
const msg = `Unable to decode inline image: "${reason}".`;
if (!this.options.ignoreErrors) {
throw new Error(msg);
}
warn(msg);
}
return; return;
} }

View file

@ -0,0 +1,2 @@
https://github.com/mozilla/pdf.js/files/14607428/image1.pdf

View file

@ -9771,5 +9771,13 @@
"rounds": 1, "rounds": 1,
"annotations": true, "annotations": true,
"type": "eq" "type": "eq"
},
{
"id": "issue17794",
"file": "pdfs/issue17794.pdf",
"md5": "a66b5b938cb44ae241cad845cc3b5d2d",
"rounds": 1,
"link": true,
"type": "eq"
} }
] ]