diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 71a1efe..76d0156 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -1612,10 +1612,27 @@ GBool PDFDoc::markAnnotations(Object *annotsObj, XRef *xRef, XRef *countRef, Gui type.free(); continue; } else { - array->remove(i); + Object page; + getXRef()->fetch(obj2.getRef().num, obj2.getRef().gen, &page); + if (page.isDict()) { + Object pagetype; + Dict *dict = page.getDict(); + dict->lookup("Type", &pagetype); + if (!pagetype.isName() || strcmp(pagetype.getName(), "Page") != 0) { + obj1.free(); + obj2.free(); + type.free(); + page.free(); + pagetype.free(); + continue; + } + pagetype.free(); + } + page.free(); obj1.free(); obj2.free(); type.free(); + array->remove(i); modified = gTrue; continue; }