[evolution-exchange/gnome-2-26] Prevent using NULL in libical functions



commit f6ac707ee732e522a3efee0b25f7681a5f9054b0
Author: Milan Crha <mcrha redhat com>
Date:   Mon Apr 27 12:24:24 2009 +0200

    Prevent using NULL in libical functions
    
            ** Fix for bug #577105
---
 ChangeLog                         |    8 ++++++++
 calendar/e-cal-backend-exchange.c |   21 +++++++++++++--------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e7c5024..d5a15d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-04-27  Milan Crha  <mcrha redhat com>
+
+	** Fix for bug #577105
+
+	* calendar/e-cal-backend-exchange.c: (save_object),
+	(e_cal_backend_exchange_modify_object),	(get_object),
+	(free_exchange_comp): Prevent using NULL in libical functions.
+
 2009-03-16  Srinivasa Ragavan  <sragavan novell com>
 
 	* NEWS: Evolution Exchange 2.26.0 release and version bump
diff --git a/calendar/e-cal-backend-exchange.c b/calendar/e-cal-backend-exchange.c
index 09630be..cdfda07 100644
--- a/calendar/e-cal-backend-exchange.c
+++ b/calendar/e-cal-backend-exchange.c
@@ -276,12 +276,16 @@ save_object (gpointer key, gpointer value, gpointer vcalcomp)
 	icalcomponent *icalcomp;
 	GList *l;
 
-	icalcomp = icalcomponent_new_clone (ecomp->icomp);
-	icalcomponent_add_component (vcalcomp, icalcomp);
+	if (ecomp->icomp) {
+		icalcomp = icalcomponent_new_clone (ecomp->icomp);
+		icalcomponent_add_component (vcalcomp, icalcomp);
+	}
 
 	for (l = ecomp->instances; l; l = l->next) {
-		icalcomp = icalcomponent_new_clone (l->data);
-		icalcomponent_add_component (vcalcomp, icalcomp);
+		if (l->data) {
+			icalcomp = icalcomponent_new_clone (l->data);
+			icalcomponent_add_component (vcalcomp, icalcomp);
+		}
 	}
 }
 
@@ -838,7 +842,8 @@ e_cal_backend_exchange_modify_object (ECalBackendExchange *cbex,
 		return FALSE;
 
 	if (mod == CALOBJ_MOD_ALL || icaltime_is_null_time (rid) || discard_detached) {
-		icalcomponent_free (ecomp->icomp);
+		if (ecomp->icomp)
+			icalcomponent_free (ecomp->icomp);
 		ecomp->icomp = icalcomponent_new_clone (comp);
 		if (discard_detached && !icaltime_is_null_time (rid))
 			discard_detached_instance (ecomp, rid);
@@ -1020,7 +1025,7 @@ get_object (ECalBackendSync *backend, EDataCal *cal,
 
 			*object = icalcomponent_as_ical_string_r (vcalcomp);
 			icalcomponent_free (vcalcomp);
-		} else {
+		} else if (ecomp->icomp) {
 			/* There are no detached instances. Send only the master object */
 			*object = icalcomponent_as_ical_string_r (ecomp->icomp);
 		}
@@ -1633,7 +1638,6 @@ check_change_type (gpointer key, gpointer value, gpointer data)
 	*/
 	if (!ecomp)
 		return;
-	icomp = ecomp->icomp;
 	l = ecomp->instances;
 	for (icomp = ecomp->icomp; l; icomp = l->data, l = l->next) {
 		if (!icomp)
@@ -2127,7 +2131,8 @@ free_exchange_comp (gpointer value)
 	g_free (ecomp->href);
 	g_free (ecomp->lastmod);
 
-	icalcomponent_free (ecomp->icomp);
+	if (ecomp->icomp)
+		icalcomponent_free (ecomp->icomp);
 
 	for (inst = ecomp->instances; inst; inst = inst->next)
 		icalcomponent_free (inst->data);



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