[poppler] poppler/poppler: Annot.cc,1.5,1.6 Annot.h,1.2,1.3

Albert Astals Cid aacid at kemper.freedesktop.org
Wed Dec 27 15:15:08 PST 2006


Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv23985/poppler

Modified Files:
	Annot.cc Annot.h 
Log Message:
* poppler/Annot.cc:
* poppler/Annot.h: Add type checking to processing of "Rect". Patch by Scott Turner <scotty1024 at mac.com>


Index: Annot.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Annot.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Annot.cc	6 Feb 2006 18:50:11 -0000	1.5
+++ Annot.cc	27 Dec 2006 23:15:06 -0000	1.6
@@ -30,30 +30,27 @@
   GBool regen, isTextField;
   double t;
 
-  ok = gFalse;
+  ok = gTrue;
   xref = xrefA;
   appearBuf = NULL;
 
   if (dict->lookup("Rect", &obj1)->isArray() &&
       obj1.arrayGetLength() == 4) {
-    //~ should check object types here
-    obj1.arrayGet(0, &obj2);
-    xMin = obj2.getNum();
-    obj2.free();
-    obj1.arrayGet(1, &obj2);
-    yMin = obj2.getNum();
-    obj2.free();
-    obj1.arrayGet(2, &obj2);
-    xMax = obj2.getNum();
-    obj2.free();
-    obj1.arrayGet(3, &obj2);
-    yMax = obj2.getNum();
-    obj2.free();
-    if (xMin > xMax) {
-      t = xMin; xMin = xMax; xMax = t;
-    }
-    if (yMin > yMax) {
-      t = yMin; yMin = yMax; yMax = t;
+    readArrayNum(&obj1, 0, &xMin);
+    readArrayNum(&obj1, 1, &yMin);
+    readArrayNum(&obj1, 2, &xMax);
+    readArrayNum(&obj1, 3, &yMax);
+    if (ok) {
+      if (xMin > xMax) {
+        t = xMin; xMin = xMax; xMax = t;
+      }
+      if (yMin > yMax) {
+        t = yMin; yMin = yMax; yMax = t;
+      }
+    } else {
+      //~ this should return an error
+      xMin = yMin = 0;
+      xMax = yMax = 1;
     }
   } else {
     //~ this should return an error
@@ -112,6 +109,19 @@
 #endif
 }
 
+void Annot::readArrayNum(Object *pdfArray, int key, double *value) {
+  Object valueObject;
+
+  pdfArray->arrayGet(key, &valueObject);
+  if (valueObject.isNum()) {
+    *value = valueObject.getNum();
+  } else {
+    *value = 0;
+    ok = gFalse;
+  }
+  valueObject.free();
+}
+
 Annot::~Annot() {
   appearance.free();
   if (appearBuf) {

Index: Annot.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/Annot.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Annot.h	16 Oct 2005 14:54:17 -0000	1.2
+++ Annot.h	27 Dec 2006 23:15:06 -0000	1.3
@@ -36,6 +36,7 @@
 private:
 
   void generateAppearance(Dict *acroForm, Dict *dict);
+  void readArrayNum(Object *pdfArray, int key, double *value);
 
   XRef *xref;			// the xref table for this PDF file
   Object appearance;		// a reference to the Form XObject stream



More information about the poppler mailing list