[poppler] 3 commits - poppler/OptionalContent.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Fri Mar 14 17:25:36 PDT 2008


 poppler/OptionalContent.cc |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

New commits:
commit 9bba2748985049515bfd9c9b44f26b92fa704078
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sat Mar 15 01:11:39 2008 +0100

    Some more free

diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index 0ceaafd..d7bf628 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -40,6 +40,8 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) :
   ocgObject->dictLookup("OCGs", &ocgList);
   if (!ocgList.isArray()) {
     error(-1, "Expected the optional content group list, but wasn't able to find it, or it isn't an Array");
+    ocgList.free();
+    return;
   }
 
   // we now enumerate over the ocgList, and build up the optionalContentGroups list.
@@ -65,6 +67,9 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) :
   ocgObject->dictLookup("D", &defaultOcgConfig);
   if (!defaultOcgConfig.isDict()) {
     error(-1, "Expected the default config, but wasn't able to find it, or it isn't a Dictionary");
+    defaultOcgConfig.free();
+    ocgList.free();
+    return;
   }
 #if 0
   // this is untested - we need an example showing BaseState
commit bfc308935fa138e27c4d2ad0e1c1cad20eba8e8a
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sat Mar 15 01:05:32 2008 +0100

    Use error instead of printf

diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index bec309a..0ceaafd 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -17,6 +17,7 @@
 #include "goo/gmem.h"
 #include "goo/GooString.h"
 #include "goo/GooList.h"
+#include "Error.h"
 // #include "PDFDocEncoding.h"
 #include "OptionalContent.h"
 
@@ -38,7 +39,7 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) :
   Object ocgList;
   ocgObject->dictLookup("OCGs", &ocgList);
   if (!ocgList.isArray()) {
-    printf("PROBLEM: expected the optional content group list, but wasn't able to find it, or it isn't an Array\n");
+    error(-1, "Expected the optional content group list, but wasn't able to find it, or it isn't an Array");
   }
 
   // we now enumerate over the ocgList, and build up the optionalContentGroups list.
@@ -63,7 +64,7 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) :
   Object defaultOcgConfig;
   ocgObject->dictLookup("D", &defaultOcgConfig);
   if (!defaultOcgConfig.isDict()) {
-    printf("PROBLEM: expected the default config, but wasn't able to find it, or it isn't a Dictionary\n");
+    error(-1, "Expected the default config, but wasn't able to find it, or it isn't a Dictionary");
   }
 #if 0
   // this is untested - we need an example showing BaseState
@@ -89,7 +90,7 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) :
       OptionalContentGroup *group = findOcgByRef( reference.getRef() );
       reference.free();
       if (!group) {
-	printf("Couldn't find group for reference\n");
+	error(-1, "Couldn't find group for reference");
 	break;
       }
       group->setState(OptionalContentGroup::On);
@@ -112,7 +113,7 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) :
       OptionalContentGroup *group = findOcgByRef( reference.getRef() );
       reference.free();
       if (!group) {
-	printf("Couldn't find group for reference to set OFF\n");
+	error(-1, "Couldn't find group for reference to set OFF");
 	break;
       }
       group->setState(OptionalContentGroup::Off);
@@ -176,7 +177,7 @@ bool OCGs::optContentIsVisible( Object *dictRef )
   bool result = true;
   dictRef->fetch( m_xref, &dictObj );
   if ( ! dictObj.isDict() ) {
-    printf( "Unexpected oc reference target: %i\n", dictObj.getType() );
+    error(-1, "Unexpected oc reference target: %i", dictObj.getType() );
     dictObj.free();
     return result;
   }
@@ -213,7 +214,7 @@ bool OCGs::optContentIsVisible( Object *dictRef )
   } else if ( dictType.isName("OCG") ) {
     OptionalContentGroup* oc = findOcgByRef( dictRef->getRef() );
     if ( oc ) {
-      printf("Found valid group object\n");
+//       printf("Found valid group object\n");
       if ( oc->state() == OptionalContentGroup::Off ) {
 	result=false;
       }
@@ -292,7 +293,7 @@ OptionalContentGroup::OptionalContentGroup(Dict *ocgDict, XRef *xrefA)
   Object ocgName;
   ocgDict->lookupNF("Name", &ocgName);
   if (!ocgName.isString()) {
-    printf("PROBLEM: expected the name of the OCG, but wasn't able to find it, or it isn't a String\n");
+    error(-1, "Expected the name of the OCG, but wasn't able to find it, or it isn't a String");
   } else {
     m_name = new GooString( ocgName.getString() );
   }
commit 998b1523ee653c1585f03b4a580e0d95ba694aca
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sat Mar 15 01:02:31 2008 +0100

    Some free

diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index b081add..bec309a 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -46,6 +46,7 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) :
     Object ocg;
     ocgList.arrayGet(i, &ocg);
     if (!ocg.isDict()) {
+      ocg.free();
       break;
     }
     OptionalContentGroup *thisOptionalContentGroup = new OptionalContentGroup(ocg.getDict(), xref);
@@ -82,6 +83,7 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) :
       on.arrayGetNF(i, &reference);
       if (!reference.isRef()) {
 	// there can be null entries
+	reference.free();
 	break;
       }
       OptionalContentGroup *group = findOcgByRef( reference.getRef() );
@@ -104,6 +106,7 @@ OCGs::OCGs(Object *ocgObject, XRef *xref) :
       off.arrayGetNF(i, &reference);
       if (!reference.isRef()) {
 	// there can be null entries
+	reference.free();
 	break;
       }
       OptionalContentGroup *group = findOcgByRef( reference.getRef() );


More information about the poppler mailing list