diff options
Diffstat (limited to 'Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.cc')
-rw-r--r-- | Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.cc | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.cc b/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.cc index 7b2b9855669..33534dafd60 100644 --- a/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.cc +++ b/Build/source/libs/xpdf/xpdf-src/xpdf/AcroForm.cc @@ -8,10 +8,6 @@ #include <aconf.h> -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - #include <stdlib.h> #include <math.h> #include "gmem.h" @@ -343,8 +339,12 @@ AcroForm *AcroForm::load(PDFDoc *docA, Catalog *catalog, Object *acroFormObjA) { AcroForm *acroForm; AcroFormField *field; Object xfaObj, fieldsObj, annotsObj, annotRef, annotObj, obj1, obj2; + char *touchedObjs; int pageNum, i, j; + touchedObjs = (char *)gmalloc(docA->getXRef()->getNumObjects()); + memset(touchedObjs, 0, docA->getXRef()->getNumObjects()); + // this is the normal case: acroFormObj is a dictionary, as expected if (acroFormObjA->isDict()) { acroForm = new AcroForm(docA, acroFormObjA); @@ -372,11 +372,12 @@ AcroForm *AcroForm::load(PDFDoc *docA, Catalog *catalog, Object *acroFormObjA) { } obj1.free(); delete acroForm; + gfree(touchedObjs); return NULL; } for (i = 0; i < obj1.arrayGetLength(); ++i) { obj1.arrayGetNF(i, &obj2); - acroForm->scanField(&obj2); + acroForm->scanField(&obj2, touchedObjs); obj2.free(); } obj1.free(); @@ -400,7 +401,7 @@ AcroForm *AcroForm::load(PDFDoc *docA, Catalog *catalog, Object *acroFormObjA) { annotRef.fetch(acroForm->doc->getXRef(), &annotObj); if (annotObj.isDict()) { if (annotObj.dictLookup("Subtype", &obj1)->isName("Widget")) { - acroForm->scanField(&annotRef); + acroForm->scanField(&annotRef, touchedObjs); } obj1.free(); } @@ -431,7 +432,7 @@ AcroForm *AcroForm::load(PDFDoc *docA, Catalog *catalog, Object *acroFormObjA) { annotRef.fetch(acroForm->doc->getXRef(), &annotObj); if (annotObj.isDict()) { if (annotObj.dictLookup("Subtype", &obj1)->isName("Widget")) { - acroForm->scanField(&annotRef); + acroForm->scanField(&annotRef, touchedObjs); } obj1.free(); } @@ -449,6 +450,8 @@ AcroForm *AcroForm::load(PDFDoc *docA, Catalog *catalog, Object *acroFormObjA) { } } + gfree(touchedObjs); + return acroForm; } @@ -512,12 +515,22 @@ int AcroForm::lookupAnnotPage(Object *annotRef) { return 0; } -void AcroForm::scanField(Object *fieldRef) { +void AcroForm::scanField(Object *fieldRef, char *touchedObjs) { AcroFormField *field; Object fieldObj, kidsObj, kidRef, kidObj, subtypeObj; GBool isTerminal; int i; + // check for an object loop + if (fieldRef->isRef()) { + if (fieldRef->getRefNum() < 0 || + fieldRef->getRefNum() >= doc->getXRef()->getNumObjects() || + touchedObjs[fieldRef->getRefNum()]) { + return; + } + touchedObjs[fieldRef->getRefNum()] = 1; + } + fieldRef->fetch(doc->getXRef(), &fieldObj); if (!fieldObj.isDict()) { error(errSyntaxError, -1, "AcroForm field object is wrong type"); @@ -545,7 +558,7 @@ void AcroForm::scanField(Object *fieldRef) { if (!isTerminal) { for (i = 0; !isTerminal && i < kidsObj.arrayGetLength(); ++i) { kidsObj.arrayGetNF(i, &kidRef); - scanField(&kidRef); + scanField(&kidRef, touchedObjs); kidRef.free(); } } @@ -2033,21 +2046,18 @@ void AcroFormField::drawText(GString *text, GString *da, GfxFontDict *fontDict, wMax = dx - 2 * border - 4; -#if 1 //~tmp // this is a kludge that appears to match Adobe's behavior if (height > 15) { topBorder = 5; } else { topBorder = 2; } -#else - topBorder = 5; -#endif // compute font autosize if (fontSize == 0) { for (fontSize = 10; fontSize > 1; --fontSize) { yy = dy - topBorder; + w = 0; i = 0; while (i < text2->getLength()) { getNextLine(text2, i, font, fontSize, wMax, &j, &w, &k); @@ -3183,7 +3193,7 @@ GBool AcroFormField::unicodeStringEqual(Unicode *u, int unicodeLength, return gFalse; } for (int i = 0; i < unicodeLength; ++i) { - if ((s->getChar(i) & 0xff) != u[i]) { + if ((Unicode)(s->getChar(i) & 0xff) != u[i]) { return gFalse; } } @@ -3193,7 +3203,7 @@ GBool AcroFormField::unicodeStringEqual(Unicode *u, int unicodeLength, GBool AcroFormField::unicodeStringEqual(Unicode *u, int unicodeLength, const char *s) { for (int i = 0; i < unicodeLength; ++i) { - if (!s[i] || (s[i] & 0xff) != u[i]) { + if (!s[i] || (Unicode)(s[i] & 0xff) != u[i]) { return gFalse; } } |