[poppler] poppler/glib: poppler-action.cc, 1.7, 1.8 poppler-document.cc, 1.34, 1.35 poppler-page.cc, 1.47, 1.48

Kristian Høgsberg krh at kemper.freedesktop.org
Fri May 19 12:22:01 PDT 2006


Update of /cvs/poppler/poppler/glib
In directory kemper:/tmp/cvs-serv22952/glib

Modified Files:
	poppler-action.cc poppler-document.cc poppler-page.cc 
Log Message:
2006-05-19  Kristian Høgsberg  <krh at redhat.com>

	Memory leak patch from Carlos Garcia Campos (#6947).

	* glib/poppler-action.cc:
	* glib/poppler-document.cc:
	* glib/poppler-page.cc:
	* poppler/CairoFontEngine.cc:
	* poppler/CairoFontEngine.h:
	* poppler/CairoOutputDev.cc:
	* poppler/CairoOutputDev.h:
	* poppler/Gfx.cc:
	* poppler/TextOutputDev.cc:  Fix various memory leaks.



Index: poppler-action.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-action.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- poppler-action.cc	16 Apr 2006 22:59:44 -0000	1.7
+++ poppler-action.cc	19 May 2006 19:21:59 -0000	1.8
@@ -244,6 +244,7 @@
 dest_new_named (UGooString *named_dest)
 {
 	PopplerDest *dest;
+	gchar *name;
 
 	dest = g_new0 (PopplerDest, 1);
 
@@ -253,7 +254,9 @@
 	}
 
 	dest->type = POPPLER_DEST_NAMED;
-	dest->named_dest = g_strdup (named_dest->getCString ());
+	name = named_dest->getCString ();
+	dest->named_dest = g_strdup (name);
+	delete[] name;
 
 	return dest;
 }
@@ -317,10 +320,10 @@
 	      LinkLaunch    *link)
 {
 	if (link->getFileName()) {
-		action->launch.file_name = link->getFileName()->getCString ();
+		action->launch.file_name = g_strdup (link->getFileName()->getCString ());
 	}
 	if (link->getParams()) {
-		action->launch.params = link->getParams()->getCString ();
+		action->launch.params = g_strdup (link->getParams()->getCString ());
 	}
 }
 

Index: poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-document.cc,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- poppler-document.cc	16 Apr 2006 22:59:44 -0000	1.34
+++ poppler-document.cc	19 May 2006 19:21:59 -0000	1.35
@@ -411,7 +411,7 @@
   int year, mon, day, hour, min, sec;
   int scanned_items;
   struct tm *time;
-  gchar *date_string;
+  gchar *date_string, *ds;
   GTime result;
 
   if (!info_dict->lookup ((gchar *)key, &obj)->isString ()) {
@@ -428,7 +428,8 @@
   } else {
     date_string = g_strndup (goo_value->getCString (), goo_value->getLength ());
   }
-
+  ds = date_string;
+  
   /* See PDF Reference 1.3, Section 3.8.2 for PDF Date representation */
 
   if (date_string [0] == 'D' && date_string [1] == ':')
@@ -438,9 +439,12 @@
   scanned_items = sscanf (date_string, "%4d%2d%2d%2d%2d%2d",
 		&year, &mon, &day, &hour, &min, &sec);
 
-  if (scanned_items != 6)
+  if (scanned_items != 6) {
+    obj.free ();
+    g_free (ds);
     return;
-
+  }
+  
   /* Workaround for y2k bug in Distiller 3, hoping that it won't
    * be used after y2.2k */
   if (year < 1930 && strlen (date_string) > 14) {
@@ -448,9 +452,12 @@
     scanned_items = sscanf (date_string, "%2d%3d%2d%2d%2d%2d%2d",
 		&century, &years_since_1900, &mon, &day, &hour, &min, &sec);
 						
-    if (scanned_items != 7)
+    if (scanned_items != 7) {
+      obj.free ();
+      g_free (ds);
       return;
-	
+    }
+    
     year = century * 100 + years_since_1900;
   }
 
@@ -468,12 +475,15 @@
  
   /* compute tm_wday and tm_yday and check date */
   if (mktime (time) == (time_t) - 1) {
+    obj.free ();
+    g_free (ds);
     return;
   } else {
   	result = mktime (time);
   }       
     
   obj.free ();
+  g_free (ds);
   
   g_value_set_int (value, result);
 }
@@ -540,6 +550,7 @@
       document->doc->getDocInfo (&obj);
       if (obj.isDict ())
 	info_dict_get_string (obj.getDict(), "Title", value);
+      obj.free ();
       break;
     case PROP_FORMAT:
       str = g_strndup("PDF-", 15); /* allocates 16 chars, pads with \0s */
@@ -551,36 +562,43 @@
       document->doc->getDocInfo (&obj);
       if (obj.isDict ())
 	info_dict_get_string (obj.getDict(), "Author", value);
+      obj.free ();
       break;
     case PROP_SUBJECT:
       document->doc->getDocInfo (&obj);
       if (obj.isDict ())
 	info_dict_get_string (obj.getDict(), "Subject", value);
+      obj.free ();
       break;
     case PROP_KEYWORDS:
       document->doc->getDocInfo (&obj);
       if (obj.isDict ())
 	info_dict_get_string (obj.getDict(), "Keywords", value);
+      obj.free ();
       break;
     case PROP_CREATOR:
       document->doc->getDocInfo (&obj);
       if (obj.isDict ())
 	info_dict_get_string (obj.getDict(), "Creator", value);
+      obj.free ();
       break;
     case PROP_PRODUCER:
       document->doc->getDocInfo (&obj);
       if (obj.isDict ())
 	info_dict_get_string (obj.getDict(), "Producer", value);
+      obj.free ();
       break;
     case PROP_CREATION_DATE:
       document->doc->getDocInfo (&obj);
       if (obj.isDict ())
 	info_dict_get_date (obj.getDict(), "CreationDate", value);
+      obj.free ();
       break;
     case PROP_MOD_DATE:
       document->doc->getDocInfo (&obj);
       if (obj.isDict ())
 	info_dict_get_date (obj.getDict(), "ModDate", value);
+      obj.free ();
 	break;
     case PROP_LINEARIZED:
       if (document->doc->isLinearized ()) {	
@@ -1017,7 +1035,6 @@
 		return;
 
 	g_object_unref (iter->document);
-//	delete iter->items;
 	g_free (iter);
 	
 }

Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.cc,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- poppler-page.cc	2 May 2006 04:38:39 -0000	1.47
+++ poppler-page.cc	19 May 2006 19:21:59 -0000	1.48
@@ -860,6 +860,8 @@
 		map_list = g_list_prepend (map_list, mapping);
 	}
 
+	delete links;
+
 	return map_list;
 }
 



More information about the poppler mailing list