[evolution-data-server/gnome-2-28] Bug #603437 - Fix few memory leaks



commit b5f9bd718a879bed5fa9e1f6a30569dc3e7ef040
Author: Milan Crha <mcrha redhat com>
Date:   Thu Dec 10 13:17:39 2009 +0100

    Bug #603437 - Fix few memory leaks

 .../groupwise/e-cal-backend-groupwise-utils.c      |    7 ++++++-
 .../backends/groupwise/e-cal-backend-groupwise.c   |   11 +++++------
 calendar/backends/weather/e-cal-backend-weather.c  |    2 ++
 calendar/libecal/e-cal-util.c                      |    5 ++++-
 calendar/libedata-cal/e-cal-backend-file-store.c   |    6 +++++-
 5 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c b/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
index f572db3..a22f377 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
@@ -2090,8 +2090,13 @@ e_cal_backend_groupwise_store_settings (GwSettings *hold)
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
 
 	/* TODO implement send options for Notes */
-	if (kind == ICAL_VJOURNAL_COMPONENT)
+	if (kind == ICAL_VJOURNAL_COMPONENT) {
+		g_object_unref (gconf);
+		g_object_unref (hold->opts);
+		g_free (hold);
+
 		return FALSE;
+	}
 
 	gopts = e_gw_sendoptions_get_general_options (opts);
 	if (kind == ICAL_VEVENT_COMPONENT) {
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise.c b/calendar/backends/groupwise/e-cal-backend-groupwise.c
index 5c1d24f..3cd944b 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise.c
@@ -338,7 +338,7 @@ get_deltas (gpointer handle)
 	ECalBackendStore *store;
 	EGwConnectionStatus status;
 	icalcomponent_kind kind;
-	GList *item_list, *total_list = NULL, *l;
+	GList *item_list = NULL, *total_list = NULL, *l;
 	GSList *cache_ids = NULL, *ls;
 	GPtrArray *uid_array = NULL;
 	gchar *time_string = NULL;
@@ -452,6 +452,7 @@ get_deltas (gpointer handle)
 
 		e_cal_component_get_uid (modified_comp, &uid);
 		cache_comp = e_cal_backend_store_get_component (store, uid, rid);
+		g_free (rid);
 		e_cal_component_commit_sequence (modified_comp);
 
 		e_cal_component_get_last_modified (modified_comp, &tt);
@@ -474,7 +475,6 @@ get_deltas (gpointer handle)
 
 			g_free (modif_comp_str);
 			g_free (cache_comp_str);
-			g_free (rid);
 			cache_comp_str = NULL;
 			e_cal_backend_store_put_component (store, modified_comp);
 		}
@@ -544,12 +544,10 @@ get_deltas (gpointer handle)
 		status = e_gw_connection_read_cal_ids (cnc, cbgw->priv->container_id, cursor, FALSE, CURSOR_ICALID_LIMIT, position, &item_list);
 		if (status != E_GW_CONNECTION_STATUS_OK) {
 			if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) {
-				g_static_mutex_unlock (&connecting);
-				return TRUE;
+				goto err_done;
 			}
 			e_cal_backend_groupwise_notify_error_code (cbgw, status);
-			g_static_mutex_unlock (&connecting);
-			return TRUE;
+			goto err_done;
 		}
 
 		if (!item_list  || g_list_length (item_list) == 0)
@@ -663,6 +661,7 @@ get_deltas (gpointer handle)
 	g_ptr_array_foreach (uid_array, (GFunc) g_free, NULL);
 	g_ptr_array_free (uid_array, TRUE);
 
+ err_done:
 	if (item_list) {
 		g_list_free (item_list);
 		item_list = NULL;
diff --git a/calendar/backends/weather/e-cal-backend-weather.c b/calendar/backends/weather/e-cal-backend-weather.c
index 6b8aa06..3079b9e 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -182,6 +182,7 @@ finished_retrieval_cb (WeatherInfo *info, ECalBackendWeather *cbw)
 		obj = icalcomponent_as_ical_string_r (icomp);
 		e_cal_backend_notify_object_created (E_CAL_BACKEND (cbw), obj);
 		g_free (obj);
+		g_object_unref (comp);
 
 		forecasts = weather_info_get_forecast_list (info);
 		if (forecasts) {
@@ -199,6 +200,7 @@ finished_retrieval_cb (WeatherInfo *info, ECalBackendWeather *cbw)
 						obj = icalcomponent_as_ical_string_r (icomp);
 						e_cal_backend_notify_object_created (E_CAL_BACKEND (cbw), obj);
 						g_free (obj);
+						g_object_unref (comp);
 					}
 				}
 			}
diff --git a/calendar/libecal/e-cal-util.c b/calendar/libecal/e-cal-util.c
index e4eefb0..da32e2b 100644
--- a/calendar/libecal/e-cal-util.c
+++ b/calendar/libecal/e-cal-util.c
@@ -123,9 +123,12 @@ e_cal_util_new_component (icalcomponent_kind kind)
 {
 	icalcomponent *comp;
 	struct icaltimetype dtstamp;
+	gchar *uid;
 
 	comp = icalcomponent_new (kind);
-	icalcomponent_set_uid (comp, e_cal_component_gen_uid ());
+	uid = e_cal_component_gen_uid ();
+	icalcomponent_set_uid (comp, uid);
+	g_free (uid);
 	dtstamp = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
 	icalcomponent_set_dtstamp (comp, dtstamp);
 
diff --git a/calendar/libedata-cal/e-cal-backend-file-store.c b/calendar/libedata-cal/e-cal-backend-file-store.c
index da32f56..6e7bb44 100644
--- a/calendar/libedata-cal/e-cal-backend-file-store.c
+++ b/calendar/libedata-cal/e-cal-backend-file-store.c
@@ -637,10 +637,14 @@ scan_vcalendar (ECalBackendFileStore *fstore, icalcomponent *top_icalcomp)
 
 		comp = e_cal_component_new ();
 
-		if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp)))
+		if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp))) {
+			g_object_unref (comp);
 			continue;
+		}
 
 		put_component (fstore, comp);
+
+		g_object_unref (comp);
 	}
 }
 



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