Commit eb7940e7 authored by Albert Astals Cid's avatar Albert Astals Cid

Filter out repeated forms

Some files like the one from KDE bug 426467 has the same signature
repeated 23 times in the Fields field, just return it one
parent 56cf80b2
......@@ -2005,6 +2005,7 @@ Form::Form(PDFDoc *docA, Object *acroFormA)
obj1 = acroForm->dictLookup("Fields");
if (obj1.isArray()) {
Array *array = obj1.getArray();
std::set<Ref> alreadyReadRefs;
for (int i = 0; i < array->getLength(); i++) {
Object obj2 = array->get(i);
const Object &oref = array->getNF(i);
......@@ -2018,6 +2019,11 @@ Form::Form(PDFDoc *docA, Object *acroFormA)
continue;
}
if (alreadyReadRefs.find(oref.getRef()) != alreadyReadRefs.end()) {
continue;
}
alreadyReadRefs.insert(oref.getRef());
if (numFields >= size) {
size += 16;
rootFields = (FormField **)greallocn(rootFields, size, sizeof(FormField *));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment