[evolution-patches] [Exchange] Memory leaks fix.



Hi,

Attached patch fixes few memory leaks in Evolution-exchange.

Thanks,

V. Varadhan

? memory-leaks.fix
? valgrind-report-11-08-2009PM.txt
? valgrind-report-11-08.txt
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-exchange/ChangeLog,v
retrieving revision 1.369
diff -u -p -r1.369 ChangeLog
--- ChangeLog	9 Aug 2005 08:15:40 -0000	1.369
+++ ChangeLog	11 Aug 2005 14:59:15 -0000
@@ -1,3 +1,10 @@
+2005-08-11  Veerapuram Varadhan <vvaradhan novell com>
+
+	* calendar/e-cal-backend-exchange-calendar.c (add_ical):
+	* calendar/e-cal-backend-exchange.c (get_attachment):
+	* storage/e-folder-exchange.c (e_folder_exchange_save_to_file):
+	Memory leak fix.
+	
 2005-08-08  Sarfraaz Ahmed <asarfraaz novell com>
 
 	* configure.in : Bumped the version to 2.3.7
Index: calendar/e-cal-backend-exchange-calendar.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/calendar/e-cal-backend-exchange-calendar.c,v
retrieving revision 1.44
diff -u -p -r1.44 e-cal-backend-exchange-calendar.c
--- calendar/e-cal-backend-exchange-calendar.c	14 Jun 2005 13:12:43 -0000	1.44
+++ calendar/e-cal-backend-exchange-calendar.c	11 Aug 2005 14:59:15 -0000
@@ -208,17 +208,21 @@ add_ical (ECalBackendExchange *cbex, con
 		}
 		if (attachment_list) {
 			ecomp = e_cal_component_new ();
-			e_cal_component_set_icalcomponent (ecomp, icalcomponent_new_clone (icalcomp));
+			/* 
+			   We don't have to _clone_ the icalcomponent while setting it into 
+			   ECalComponent, because, we anyway going to _clone_ the icalcomponent
+			   inside the ECalComponent after setting the attachment_list.
+			*/
+			e_cal_component_set_icalcomponent (ecomp, icalcomp);
 			e_cal_component_set_attachment_list (ecomp, attachment_list);
 			icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (ecomp));
 			g_object_unref (ecomp);
 		}
 		status = add_vevent (cbex, href, lastmod, icalcomp);
-		icalcomponent_free (icalcomp);
-		return status;
+		goto cleanup;
 	} else if (kind != ICAL_VCALENDAR_COMPONENT) {
-		icalcomponent_free (icalcomp);
-		return FALSE;
+		status = FALSE;
+		goto cleanup;
 	}
 
 	add_timezones_from_comp (cbex, icalcomp);
@@ -243,9 +247,15 @@ add_ical (ECalBackendExchange *cbex, con
 		subcomp = icalcomponent_get_next_component (
 			icalcomp, ICAL_VEVENT_COMPONENT);
 	}
+	status = TRUE;
+
+ cleanup:
 	icalcomponent_free (icalcomp);
+	g_slist_foreach (attachment_list, g_free, NULL);
+	g_slist_free (attachment_list);
+	attachment_list = NULL;
+	return status;
 
-	return TRUE;
 }
 
 static const char *event_properties[] = {
Index: calendar/e-cal-backend-exchange.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/calendar/e-cal-backend-exchange.c,v
retrieving revision 1.37
diff -u -p -r1.37 e-cal-backend-exchange.c
--- calendar/e-cal-backend-exchange.c	28 Jul 2005 06:00:01 -0000	1.37
+++ calendar/e-cal-backend-exchange.c	11 Aug 2005 14:59:15 -0000
@@ -1306,7 +1306,7 @@ save_attach_file (const char *dest_file,
 		goto end;
 	}
 	/* FIXME : Add a ATTACH:CID:someidentifier here */
-	dest_url = g_strdup_printf ("file://%s", dest_file);
+	dest_url = g_strdup_printf ("file:///%s", dest_file);
 
 end :
 	close (fd);
@@ -1355,7 +1355,7 @@ get_attachment (ECalBackendExchange *cbe
 				attach_file_url = save_attach_file (attach_file, attach_data, stream_mem->buffer->len);
 				g_free (attach_file);
 				d(printf ("attach file name : %s\n", attach_file_url));
-				list = g_slist_append (list, g_strdup (attach_file_url));
+				list = g_slist_append (list, attach_file_url);
 
 				camel_object_unref (stream);
 			}
@@ -1492,7 +1492,10 @@ build_msg ( ECalBackendExchange *cbex, E
 		return NULL;
 	}
 	e_cal_component_set_attachment_list (comp, new_attach_list);
-
+	g_slist_foreach (new_attach_list, g_free, NULL);
+	g_slist_free (new_attach_list);
+	new_attach_list = NULL; 
+	
 	camel_medium_set_content_object (CAMEL_MEDIUM (msg), CAMEL_DATA_WRAPPER (multipart));
 	camel_object_unref (multipart);
 
Index: storage/e-folder-exchange.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/e-folder-exchange.c,v
retrieving revision 1.13
diff -u -p -r1.13 e-folder-exchange.c
--- storage/e-folder-exchange.c	23 Jun 2005 09:23:39 -0000	1.13
+++ storage/e-folder-exchange.c	11 Aug 2005 14:59:15 -0000
@@ -405,7 +405,7 @@ e_folder_exchange_save_to_file (EFolder 
 	xmlNode *root;
 	const char *name, *type, *outlook_class;
 	const char *physical_uri, *internal_uri, *permanent_uri;
-	const char *folder_size;
+	const char *folder_size = NULL;
 	long long int fsize;
 	int status;
 
@@ -414,15 +414,16 @@ e_folder_exchange_save_to_file (EFolder 
 	outlook_class = e_folder_exchange_get_outlook_class (folder);
 	physical_uri = e_folder_get_physical_uri (folder);
 	internal_uri = e_folder_exchange_get_internal_uri (folder);
+
+	g_return_val_if_fail (name && type && physical_uri && internal_uri,
+			      FALSE);
+
 	permanent_uri = e_folder_exchange_get_permanent_uri (folder);
 	if ((fsize = e_folder_exchange_get_folder_size (folder)) >= 0)
 		folder_size = g_strdup_printf ("%llu", fsize);
 	else
 		return FALSE;
 
-	g_return_val_if_fail (name && type && physical_uri && internal_uri,
-			      FALSE);
-
 	doc = xmlNewDoc ("1.0");
 	root = xmlNewDocNode (doc, NULL, "connector-folder", NULL);
 	xmlNewProp (root, "version", "1");
@@ -441,6 +442,8 @@ e_folder_exchange_save_to_file (EFolder 
 	xmlFreeDoc (doc);
 	if (status < 0)
 		unlink (filename);
+
+	g_free (folder_size);
 
 	return status == 0;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]