From 7ff47f45a22a51fee075cf4a40b434159c6893a6 Mon Sep 17 00:00:00 2001 From: Alfred Peng Date: Thu, 18 Mar 2004 06:38:35 +0000 Subject: Fix #51187 on bugzilla of ximian If "alarms" or "alarms->alarms" is NULL 2004-03-18 Alfred Peng * Fix #51187 on bugzilla of ximian * gui/alarm-notify/alarm-queue.c (query_objects_changed_cb): If "alarms" or "alarms->alarms" is NULL after querying a calendar for the alarms of a particular object, the reuse of "cqa" will probably cause evolution-alarm-notify to crash. So remove "cqa" when "alarms" or "alarms->alarms" is NULL. Otherwise update it. svn path=/trunk/; revision=25112 --- calendar/gui/alarm-notify/alarm-queue.c | 63 +++++++++++++++++---------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'calendar/gui/alarm-notify') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 0ad2f4c1fe..85bc818f55 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -547,39 +547,42 @@ query_objects_changed_cb (ECal *client, GList *objects, gpointer data) else { GSList *sl; - /* if already in the list, just update it */ - remove_alarms (cqa, FALSE); - cqa->alarms = alarms; - cqa->queued_alarms = NULL; - - /* add the new alarms */ - for (sl = cqa->alarms->alarms; sl; sl = sl->next) { - ECalComponentAlarmInstance *instance; - gpointer alarm_id; - QueuedAlarm *qa; - - instance = sl->data; - - alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL); - if (!alarm_id) { - g_message ("obj_updated_cb(): Could not schedule a trigger for " - "%ld, discarding...", (long) instance->trigger); - continue; - } - - qa = g_new (QueuedAlarm, 1); - qa->alarm_id = alarm_id; - qa->instance = instance; - qa->snooze = FALSE; - - cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa); + /* if the alarms or the alarms list is empty, just remove it */ + if (alarms == NULL || alarms->alarms == NULL) { + if (alarms) + e_cal_component_alarms_free (alarms); } + else { + /* if already in the list, just update it */ + remove_alarms (cqa, FALSE); + cqa->alarms = alarms; + cqa->queued_alarms = NULL; + + /* add the new alarms */ + for (sl = cqa->alarms->alarms; sl; sl = sl->next) { + ECalComponentAlarmInstance *instance; + gpointer alarm_id; + QueuedAlarm *qa; + + instance = sl->data; + + alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL); + if (!alarm_id) { + g_message ("obj_updated_cb(): Could not schedule a trigger for " + "%ld, discarding...", (long) instance->trigger); + continue; + } + + qa = g_new (QueuedAlarm, 1); + qa->alarm_id = alarm_id; + qa->instance = instance; + qa->snooze = FALSE; + + cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa); + } - if (cqa->queued_alarms == NULL) { - if (!cqa->expecting_update) - remove_comp (ca, uid); - } else cqa->queued_alarms = g_slist_reverse (cqa->queued_alarms); + } } } } -- cgit v1.2.3