1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 08:38:06 +02:00

Don't try to collect a nonexistent field because of an invalid ref

This commit is contained in:
Calixte Denizet 2023-11-07 15:31:43 +01:00
parent 72338ce05d
commit acc62f80de
3 changed files with 18 additions and 3 deletions

View file

@ -1713,6 +1713,9 @@ class PDFDocument {
#collectFieldObjects(name, fieldRef, promises, annotationGlobals) {
const field = this.xref.fetchIfRef(fieldRef);
if (!(field instanceof Dict)) {
return;
}
if (field.has("T")) {
const partName = stringToPDFString(field.get("T"));
name = name === "" ? partName : `${name}.${partName}`;
@ -1737,8 +1740,9 @@ class PDFDocument {
})
);
if (field.has("Kids")) {
for (const kid of field.get("Kids")) {
const kids = field.get("Kids");
if (Array.isArray(kids)) {
for (const kid of kids) {
this.#collectFieldObjects(name, kid, promises, annotationGlobals);
}
}