evolution-data-server r8592 - in trunk/calendar: . backends/caldav backends/file backends/google backends/groupwise libecal libedata-cal



Author: mcrha
Date: Thu Mar 27 13:12:34 2008
New Revision: 8592
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8592&view=rev

Log:
2008-03-27  Milan Crha  <mcrha redhat com>

	** Fix for bug #523541

	* libedata-cal/e-data-cal-view.c: (uncache_with_id_cb):
	* backends/file/e-cal-backend-file.c: (add_component),
	(e_cal_backend_file_modify_object),
	(e_cal_backend_file_receive_objects):
	* backends/groupwise/e-cal-backend-groupwise.c: (get_deltas),
	(e_cal_backend_groupwise_modify_object), (send_object):
	* backends/caldav/e-cal-backend-caldav.c: (process_object):
	* libecal/e-cal.c: (process_detached_instances),
	(e_cal_generate_instances_for_object):
	* libecal/e-cal-component.c: (e_cal_component_get_id):
	Do not leak memory returned by e_cal_component_get_recurid_as_string.
	* backends/google/e-cal-backend-google.c: (send_object):
	Do not ask for rid when not using it.



Modified:
   trunk/calendar/ChangeLog
   trunk/calendar/backends/caldav/e-cal-backend-caldav.c
   trunk/calendar/backends/file/e-cal-backend-file.c
   trunk/calendar/backends/google/e-cal-backend-google.c
   trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c
   trunk/calendar/libecal/e-cal-component.c
   trunk/calendar/libecal/e-cal.c
   trunk/calendar/libedata-cal/e-data-cal-view.c

Modified: trunk/calendar/backends/caldav/e-cal-backend-caldav.c
==============================================================================
--- trunk/calendar/backends/caldav/e-cal-backend-caldav.c	(original)
+++ trunk/calendar/backends/caldav/e-cal-backend-caldav.c	Thu Mar 27 13:12:34 2008
@@ -1937,7 +1937,7 @@
 	struct icaltimetype       now;
 	ECalComponentId          *id;
 	const char               *uid;
-	const char               *rid;
+	char                     *rid;
 	char                     *ostr;
 	char                     *oostr;
 
@@ -2083,6 +2083,7 @@
 	g_object_unref (ecomp);
 	g_free (ostr);
 	g_free (oostr);
+	g_free (rid);
 
 	if (ccomp) {
 		g_object_unref (ccomp);

Modified: trunk/calendar/backends/file/e-cal-backend-file.c
==============================================================================
--- trunk/calendar/backends/file/e-cal-backend-file.c	(original)
+++ trunk/calendar/backends/file/e-cal-backend-file.c	Thu Mar 27 13:12:34 2008
@@ -473,12 +473,13 @@
 
 	obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid);
 	if (e_cal_component_is_instance (comp)) {
-		const char *rid;
+		char *rid;
 
 		rid = e_cal_component_get_recurid_as_string (comp);
 		if (obj_data) {
 			if (g_hash_table_lookup (obj_data->recurrences, rid)) {
 				g_warning (G_STRLOC ": Tried to add an already existing recurrence");
+				g_free (rid);
 				return;
 			}
 		} else {
@@ -488,7 +489,7 @@
 			g_hash_table_insert (priv->comp_uid_hash, g_strdup (uid), obj_data);
 		}
 
-		g_hash_table_insert (obj_data->recurrences, g_strdup (rid), comp);
+		g_hash_table_insert (obj_data->recurrences, rid, comp);
 		obj_data->recurrences_list = g_list_append (obj_data->recurrences_list, comp);
 	} else {
 		/* Ensure that the UID is unique; some broken implementations spit
@@ -1903,7 +1904,8 @@
 	ECalBackendFile *cbfile;
 	ECalBackendFilePrivate *priv;
 	icalcomponent *icalcomp;
-	const char *comp_uid, *rid = NULL;
+	const char *comp_uid;
+	char *rid = NULL;
 	char *real_rid;
 	ECalComponent *comp, *recurrence;
 	ECalBackendFileObject *obj_data;
@@ -1973,6 +1975,7 @@
 			save (cbfile);
 
 			g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
+			g_free (rid);
 			return GNOME_Evolution_Calendar_Success;
 		}
 
@@ -1990,16 +1993,16 @@
 
 		/* add the detached instance */
 		g_hash_table_insert (obj_data->recurrences,
-				     g_strdup (rid),
+				     rid,
 				     comp);
 		icalcomponent_add_component (priv->icalcomp,
 					     e_cal_component_get_icalcomponent (comp));
 		priv->comp = g_list_append (priv->comp, comp);
 		obj_data->recurrences_list = g_list_append (obj_data->recurrences_list, comp);
+		rid = NULL;
 		break;
 	case CALOBJ_MOD_THISANDPRIOR :
 	case CALOBJ_MOD_THISANDFUTURE :
-		rid = e_cal_component_get_recurid_as_string (comp);
 		if (!rid || !*rid) {
 			if (old_object)
 				*old_object = e_cal_component_get_as_string (obj_data->full_object);
@@ -2008,6 +2011,8 @@
 
 			/* Add the new object */
 			add_component (cbfile, comp, TRUE);
+			g_free (rid);
+			rid = NULL;
 			break;
 		}
 
@@ -2048,12 +2053,13 @@
 
 		/* add the new detached recurrence */
 		g_hash_table_insert (obj_data->recurrences,
-				     g_strdup (e_cal_component_get_recurid_as_string (comp)),
+				     rid,
 				     comp);
 		icalcomponent_add_component (priv->icalcomp,
 					     e_cal_component_get_icalcomponent (comp));
 		priv->comp = g_list_append (priv->comp, comp);
 		obj_data->recurrences_list = g_list_append (obj_data->recurrences_list, comp);
+		rid = NULL;
 		break;
 	case CALOBJ_MOD_ALL :
 		/* in this case, we blow away all recurrences, and start over
@@ -2125,6 +2131,7 @@
 	}
 
 	save (cbfile);
+	g_free (rid);
 
 	g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
 	return GNOME_Evolution_Calendar_Success;
@@ -2284,7 +2291,7 @@
 {
 	ECalBackendFileObject *obj_data;
 	ECalBackendFilePrivate *priv;
-	const char *rid;
+	char *rid;
 	ECalComponent *comp;
 
 	priv = cbfile->priv;
@@ -2307,6 +2314,8 @@
 	else
 		remove_component (cbfile, icalcomponent_get_uid (icalcomp), obj_data);
 
+	g_free (rid);
+
 	return TRUE;
 }
 
@@ -2493,8 +2502,8 @@
 
 	/* Now we manipulate the components we care about */
 	for (l = comps; l; l = l->next) {
-		const char *uid, *rid;
-		char *object, *old_object;
+		const char *uid;
+		char *object, *old_object, *rid;
 		ECalBackendFileObject *obj_data;
 
 		subcomp = l->data;
@@ -2543,18 +2552,22 @@
 				e_cal_backend_notify_object_created (E_CAL_BACKEND (backend), object);
 				g_free (object);
 			}
+			g_free (rid);
 			break;
 		case ICAL_METHOD_ADD:
 			/* FIXME This should be doable once all the recurid stuff is done */
 			status = GNOME_Evolution_Calendar_UnsupportedMethod;
+			g_free (rid);
 			goto error;
 			break;
 		case ICAL_METHOD_COUNTER:
 			status = GNOME_Evolution_Calendar_UnsupportedMethod;
+			g_free (rid);
 			goto error;
 			break;
 		case ICAL_METHOD_DECLINECOUNTER:
 			status = GNOME_Evolution_Calendar_UnsupportedMethod;
+			g_free (rid);
 			goto error;
 			break;
 		case ICAL_METHOD_CANCEL:
@@ -2579,9 +2592,11 @@
 				g_free (old_object);
 				g_free (object);
 			}
+			g_free (rid);
 			break;
 		default:
 			status = GNOME_Evolution_Calendar_UnsupportedMethod;
+			g_free (rid);
 			goto error;
 		}
 	}

Modified: trunk/calendar/backends/google/e-cal-backend-google.c
==============================================================================
--- trunk/calendar/backends/google/e-cal-backend-google.c	(original)
+++ trunk/calendar/backends/google/e-cal-backend-google.c	Thu Mar 27 13:12:34 2008
@@ -697,12 +697,11 @@
 	ECalComponent *comp, *found_comp = NULL;
 	ECalBackendGooglePrivate *priv;
 	ECalBackendSyncStatus status = GNOME_Evolution_Calendar_OtherError;
-	const char *uid, *rid;
+	const char *uid;
 
 	priv = cbgo->priv;
 	comp = e_cal_component_new ();
 	e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));	
-	rid = e_cal_component_get_recurid_as_string (comp);	
 
 	e_cal_component_get_uid (comp, (const char **)&uid);
 	found_comp = e_cal_backend_cache_get_component (priv->cache, uid, NULL);

Modified: trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c
==============================================================================
--- trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c	(original)
+++ trunk/calendar/backends/groupwise/e-cal-backend-groupwise.c	Thu Mar 27 13:12:34 2008
@@ -419,8 +419,8 @@
 	for (; item_list != NULL; item_list = g_list_next(item_list)) {
 		EGwItem *item = NULL;
 		ECalComponent *modified_comp = NULL, *cache_comp = NULL;
-		char *cache_comp_str = NULL, *modif_comp_str;
-		const char *uid, *rid = NULL;
+		char *cache_comp_str = NULL, *modif_comp_str, *rid = NULL;
+		const char *uid;
 		int r_key;
 
 		item = E_GW_ITEM(item_list->data);
@@ -442,6 +442,7 @@
 		e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbgw), cache_comp_str, modif_comp_str);
 		g_free (modif_comp_str);
 		g_free (cache_comp_str);
+		g_free (rid);
 		cache_comp_str = NULL;
 		e_cal_backend_cache_put_component (cache, modified_comp);
 
@@ -2092,7 +2093,8 @@
 	ECalComponent *comp, *cache_comp = NULL;
 	EGwConnectionStatus status;
 	EGwItem *item, *cache_item;
-	const char *uid = NULL, *rid = NULL;
+	const char *uid = NULL;
+	char *rid = NULL;
 
 	*old_object = NULL;
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
@@ -2123,6 +2125,7 @@
 		cache_comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
 		if (!cache_comp) {
 			g_message ("CRITICAL : Could not find the object in cache");
+			g_free (rid);
 			return GNOME_Evolution_Calendar_ObjectNotFound;
 		}
 
@@ -2144,6 +2147,7 @@
 			if (status != E_GW_CONNECTION_STATUS_OK) {
 				g_object_unref (comp);
 				g_object_unref (cache_comp);
+				g_free (rid);
 				return GNOME_Evolution_Calendar_OtherError;
 			}
 
@@ -2169,6 +2173,7 @@
 				if (status != E_GW_CONNECTION_STATUS_OK) {
 					g_object_unref (comp);
 					g_object_unref (cache_comp);
+					g_free (rid);
 					return GNOME_Evolution_Calendar_OtherError;
 				}
 				e_cal_backend_cache_put_component (priv->cache, comp);
@@ -2187,6 +2192,7 @@
 		if (status != E_GW_CONNECTION_STATUS_OK) {
 			g_object_unref (comp);
 			g_object_unref (cache_comp);
+			g_free (rid);
 			return GNOME_Evolution_Calendar_OtherError;
 		}
 		/* if successful, update the cache */
@@ -2203,6 +2209,7 @@
 	*old_object = e_cal_component_get_as_string (cache_comp);
 	g_object_unref (cache_comp);
 	g_object_unref (comp);
+	g_free (rid);
 	return GNOME_Evolution_Calendar_Success;
 }
 
@@ -2637,7 +2644,8 @@
 	ECalComponent *comp, *found_comp = NULL;
 	ECalBackendGroupwisePrivate *priv;
 	ECalBackendSyncStatus status = GNOME_Evolution_Calendar_OtherError;
-	const char *uid = NULL, *rid = NULL;
+	const char *uid = NULL;
+	char *rid = NULL;
 
 	priv = cbgw->priv;
 
@@ -2647,6 +2655,8 @@
 
 	e_cal_component_get_uid (comp, (const char **) &uid);
 	found_comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
+	g_free (rid);
+	rid = NULL;
 
 	if (!found_comp) {
 		g_object_unref (comp);

Modified: trunk/calendar/libecal/e-cal-component.c
==============================================================================
--- trunk/calendar/libecal/e-cal-component.c	(original)
+++ trunk/calendar/libecal/e-cal-component.c	Thu Mar 27 13:12:34 2008
@@ -1433,7 +1433,7 @@
 
 	id = g_new0 (ECalComponentId, 1);
 	id->uid = g_strdup (icalproperty_get_uid (priv->uid));
-	id->rid = g_strdup (e_cal_component_get_recurid_as_string (comp));
+	id->rid = e_cal_component_get_recurid_as_string (comp);
 
 	return id;
 }

Modified: trunk/calendar/libecal/e-cal.c
==============================================================================
--- trunk/calendar/libecal/e-cal.c	(original)
+++ trunk/calendar/libecal/e-cal.c	Thu Mar 27 13:12:34 2008
@@ -3424,7 +3424,7 @@
 			e_cal_component_get_uid (ci->comp, &instance_uid);
 			e_cal_component_get_recurid (ci->comp, &instance_recur_id);
 			if (strcmp (uid, instance_uid) == 0) {
-				const char *i_rid = NULL, *d_rid = NULL;
+				char *i_rid = NULL, *d_rid = NULL;
 
 				i_rid = e_cal_component_get_recurid_as_string (ci->comp);
 				d_rid = e_cal_component_get_recurid_as_string (cid->comp);
@@ -3452,6 +3452,8 @@
 						       d_rid);
 
 						e_cal_component_free_datetime (&instance_recur_id.datetime);
+						g_free (i_rid);
+						g_free (d_rid);
 						continue;
 					}
 					cmp = icaltime_compare (*instance_recur_id.datetime.value,
@@ -3471,6 +3473,8 @@
 						ci->comp = comp;
 					}
 				}
+				g_free (i_rid);
+				g_free (d_rid);
 			}
 			e_cal_component_free_datetime (&instance_recur_id.datetime);
 		}
@@ -3748,8 +3752,7 @@
 	}
 
 	e_cal_component_get_uid (comp, &uid);
-	/* string might be freed at any time, keep a copy */
-	rid = g_strdup (e_cal_component_get_recurid_as_string (comp));
+	rid = e_cal_component_get_recurid_as_string (comp);
 
 	/* Get the start timezone */
 	e_cal_component_get_dtstart (comp, &datetime);
@@ -3768,7 +3771,7 @@
 	result = TRUE;
 	while (instances != NULL) {
 		struct comp_instance *ci;
-		const char *instance_rid;
+		char *instance_rid = NULL;
 
 		ci = instances->data;
 
@@ -3786,6 +3789,7 @@
 		instances = g_list_remove (instances, ci);
 		g_object_unref (ci->comp);
 		g_free (ci);
+		g_free (instance_rid);
 	}
 
 	/* clean up */

Modified: trunk/calendar/libedata-cal/e-data-cal-view.c
==============================================================================
--- trunk/calendar/libedata-cal/e-data-cal-view.c	(original)
+++ trunk/calendar/libedata-cal/e-data-cal-view.c	Thu Mar 27 13:12:34 2008
@@ -136,10 +136,12 @@
 		e_cal_component_get_uid (comp, &this_uid);
 		if (this_uid && !strcmp (id->uid, this_uid)) {
 			if (id->rid && *id->rid) {
-				const char *rid = e_cal_component_get_recurid_as_string (comp);
+				char *rid = e_cal_component_get_recurid_as_string (comp);
 
 				if (rid && !strcmp (id->rid, rid))
 					remove = TRUE;
+
+				g_free (rid);
 			} else
 				remove = TRUE;
 		}



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