[poppler] 2 commits - poppler/Form.cc poppler/Form.h

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Wed Jan 23 04:30:36 PST 2008


 poppler/Form.cc |   22 +++++++++++++++++++++-
 poppler/Form.h  |    1 +
 2 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 96c532ea4b56a147de1deb965126e31f87df588b
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Wed Jan 23 13:30:12 2008 +0100

    Fix memory leak

diff --git a/poppler/Form.cc b/poppler/Form.cc
index 92d87a3..4695600 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -220,6 +220,8 @@ void FormWidgetButton::loadDefaults ()
 	      onStr = new GooString (key);
             }
             obj3.free();
+	    if (onStr)
+	      break;
           }
         } else if (obj2.isStream()) {
           Stream *str = obj2.getStream();
@@ -229,6 +231,8 @@ void FormWidgetButton::loadDefaults ()
           onStr = new GooString ("D");
         }
         obj2.free();
+	if (onStr)
+	  break;
       }
     }
     obj1.free();
commit 6bca64407c675ca837f83a12c0f655f975f14407
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Wed Jan 23 13:27:45 2008 +0100

    Make sure default values are not loaded more than once for the same widget.

diff --git a/poppler/Form.cc b/poppler/Form.cc
index 8ab8723..92d87a3 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -53,6 +53,7 @@ FormWidget::FormWidget(XRef *xrefA, Object *aobj, unsigned num, Ref aref)
   ref = aref;
   double t;
   ID = 0;
+  defaultsLoaded = gFalse;
   fontSize = 0.0;
   modified = gFalse;
   childNum = num;
@@ -189,6 +190,11 @@ bool FormWidgetButton::isReadOnly() const
 
 void FormWidgetButton::loadDefaults ()
 {
+  if (defaultsLoaded)
+    return;
+
+  defaultsLoaded = gTrue;
+  
   Dict *dict = obj.getDict();
   Object obj1;
 
@@ -220,7 +226,7 @@ void FormWidgetButton::loadDefaults ()
           Dict *tmpDict2 = str->getDict();
           Object obj3;
           tmpDict2->lookup("Length", &obj3);
-          onStr = new GooString ("D"); 
+          onStr = new GooString ("D");
         }
         obj2.free();
       }
@@ -262,6 +268,11 @@ FormWidgetText::FormWidgetText (XRef *xrefA, Object *aobj, unsigned num, Ref ref
 
 void FormWidgetText::loadDefaults ()
 {
+  if (defaultsLoaded)
+    return;
+
+  defaultsLoaded = gTrue;
+  
   Dict *dict = obj.getDict();
   Object obj1;
 
@@ -377,6 +388,11 @@ FormWidgetChoice::FormWidgetChoice(XRef *xrefA, Object *aobj, unsigned num, Ref
 
 void FormWidgetChoice::loadDefaults ()
 {
+  if (defaultsLoaded)
+    return;
+
+  defaultsLoaded = gTrue;
+  
   Dict *dict = obj.getDict();
   Object obj1;
   if (dict->lookup("Opt", &obj1)->isArray()) {
diff --git a/poppler/Form.h b/poppler/Form.h
index e14b67d..4cac8d8 100644
--- a/poppler/Form.h
+++ b/poppler/Form.h
@@ -96,6 +96,7 @@ protected:
   Object obj;
   Ref ref;
   XRef *xref;
+  GBool defaultsLoaded;
   GBool modified;
   //index of this field in the parent's child list
   unsigned childNum;


More information about the poppler mailing list