aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-05-14 05:49:58 +0800
committerMilan Crha <mcrha@redhat.com>2010-05-14 05:49:58 +0800
commit5a124a6add633ba4af8babc8de7a8a9b8058899e (patch)
tree9fd9c187c4ac640eeb10c8586c90c3b9c5ec7380 /calendar/gui
parentb936a2301feb69f420d930f8f74436dde35b9f04 (diff)
downloadgsoc2013-evolution-5a124a6add633ba4af8babc8de7a8a9b8058899e.tar
gsoc2013-evolution-5a124a6add633ba4af8babc8de7a8a9b8058899e.tar.gz
gsoc2013-evolution-5a124a6add633ba4af8babc8de7a8a9b8058899e.tar.bz2
gsoc2013-evolution-5a124a6add633ba4af8babc8de7a8a9b8058899e.tar.lz
gsoc2013-evolution-5a124a6add633ba4af8babc8de7a8a9b8058899e.tar.xz
gsoc2013-evolution-5a124a6add633ba4af8babc8de7a8a9b8058899e.tar.zst
gsoc2013-evolution-5a124a6add633ba4af8babc8de7a8a9b8058899e.zip
Bug #607257 - Add checks for event->comp_data != NULL
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/e-cal-list-view.c3
-rw-r--r--calendar/gui/e-calendar-view.c54
-rw-r--r--calendar/gui/e-calendar-view.h8
-rw-r--r--calendar/gui/e-day-view-main-item.c12
-rw-r--r--calendar/gui/e-day-view-top-item.c13
-rw-r--r--calendar/gui/e-day-view.c302
-rw-r--r--calendar/gui/e-week-view-event-item.c39
-rw-r--r--calendar/gui/e-week-view.c155
-rw-r--r--calendar/gui/ea-cal-view-event.c10
-rw-r--r--calendar/gui/print.c9
10 files changed, 571 insertions, 34 deletions
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c
index 31ef86ddae..aabf98ce55 100644
--- a/calendar/gui/e-cal-list-view.c
+++ b/calendar/gui/e-cal-list-view.c
@@ -421,6 +421,9 @@ e_cal_list_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_
ECalComponentDateTime dtstart, dtend;
ECalComponent *comp;
+ if (!is_comp_data_valid (event))
+ return FALSE;
+
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
if (start_time) {
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 48b29337d5..77d8fd2051 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -170,6 +170,9 @@ calendar_view_delete_event (ECalendarView *cal_view,
gboolean delete = FALSE;
GError *error = NULL;
+ if (!is_comp_data_valid (event))
+ return;
+
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
vtype = e_cal_component_get_vtype (comp);
@@ -451,6 +454,9 @@ calendar_view_cut_clipboard (ESelectable *selectable)
if (!event)
continue;
+ if (!is_comp_data_valid (event))
+ continue;
+
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
@@ -560,7 +566,7 @@ calendar_view_copy_clipboard (ESelectable *selectable)
for (l = selected; l != NULL; l = l->next) {
event = (ECalendarViewEvent *) l->data;
- if (event) {
+ if (event && is_comp_data_valid (event)) {
e_cal_util_add_timezones_from_component (vcal_comp, event->comp_data->icalcomp);
add_related_timezones (vcal_comp, event->comp_data->icalcomp, event->comp_data->client);
@@ -570,6 +576,9 @@ calendar_view_copy_clipboard (ESelectable *selectable)
for (l = selected; l != NULL; l = l->next) {
event = (ECalendarViewEvent *) l->data;
+ if (!is_comp_data_valid (event))
+ continue;
+
new_icalcomp = icalcomponent_new_clone (event->comp_data->icalcomp);
/* remove RECURRENCE-IDs from copied objects */
@@ -1205,6 +1214,9 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
if (!selected)
return;
event = (ECalendarViewEvent *) selected->data;
+ if (!is_comp_data_valid (event))
+ return;
+
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
vtype = e_cal_component_get_vtype (comp);
@@ -1315,7 +1327,7 @@ e_calendar_view_open_event (ECalendarView *cal_view)
selected = e_calendar_view_get_selected_events (cal_view);
if (selected) {
ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data;
- if (event)
+ if (event && is_comp_data_valid (event))
e_calendar_view_edit_appointment (cal_view, event->comp_data->client,
event->comp_data->icalcomp, icalcomponent_get_first_property(event->comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY) != NULL);
@@ -1803,6 +1815,9 @@ e_calendar_view_get_tooltips (ECalendarViewEventData *data)
default_zone = e_calendar_view_get_timezone (data->cal_view);
pevent = data->get_view_event (data->cal_view, data->day, data->event_num);
+ if (!is_comp_data_valid (pevent))
+ return FALSE;
+
client = pevent->comp_data->client;
clone_comp = icalcomponent_new_clone (pevent->comp_data->icalcomp);
@@ -2104,3 +2119,38 @@ get_today_background (const GdkColor base_background)
return res;
}
+gboolean
+is_comp_data_valid_func (ECalendarViewEvent *event, const gchar *location)
+{
+ g_return_val_if_fail (location != NULL, FALSE);
+
+ if (!event) {
+ g_warning ("%s: event is NULL", location);
+ return FALSE;
+ }
+
+ if (!event->comp_data) {
+ g_warning ("%s: event's (%p) comp_data is NULL", location, event);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean
+is_array_index_in_bounds_func (GArray *array, gint index, const gchar *location)
+{
+ g_return_val_if_fail (location != NULL, FALSE);
+
+ if (!array) {
+ g_warning ("%s: array is NULL", location);
+ return FALSE;
+ }
+
+ if (index < 0 || index >= array->len) {
+ g_warning ("%s: index %d is out of bounds [0,%d) at array %p", location, index, array->len, array);
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h
index 62fcabcc37..6f68e6376b 100644
--- a/calendar/gui/e-calendar-view.h
+++ b/calendar/gui/e-calendar-view.h
@@ -87,6 +87,14 @@ typedef struct {
E_CALENDAR_VIEW_EVENT_FIELDS
} ECalendarViewEvent;
+/* checks if event->comp_data is not NULL, returns FALSE when it is and prints a warning on a console */
+gboolean is_comp_data_valid_func (ECalendarViewEvent *event, const gchar *location);
+#define is_comp_data_valid(_event) is_comp_data_valid_func ((ECalendarViewEvent *) (_event), G_STRFUNC)
+
+/* checks if index is within bounds for the array; returns FALSE when not, and prints a warning on a console */
+gboolean is_array_index_in_bounds_func (GArray *array, gint index, const gchar *location);
+#define is_array_index_in_bounds(_array, _index) is_array_index_in_bounds_func (_array, _index, G_STRFUNC)
+
typedef struct _ECalendarView ECalendarView;
typedef struct _ECalendarViewClass ECalendarViewClass;
typedef struct _ECalendarViewPrivate ECalendarViewPrivate;
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index 757d4e90fd..5de9b76546 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -107,6 +107,9 @@ day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *main_item,
gboolean first = TRUE;
event = &g_array_index (day_view->long_events, EDayViewEvent, event_num);
+ if (!is_comp_data_valid (event))
+ continue;
+
/* If the event is TRANSPARENT, skip it. */
if (icalcomp_is_transparent (event->comp_data->icalcomp)) {
continue;
@@ -248,9 +251,15 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
font_options = get_font_options ();
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+ if (!is_comp_data_valid (event))
+ return;
+
/* Fill in the event background. Note that for events in the first
column of the day, we might not want to paint over the vertical bar,
since that is used for multiple events. But then you can't see
@@ -866,6 +875,9 @@ day_view_main_item_draw_events_in_vbars (EDayViewMainItem *main_item,
for (event_num = 0; event_num < day_view->events[day]->len; event_num++) {
event = &g_array_index (day_view->events[day], EDayViewEvent, event_num);
+ if (!is_comp_data_valid (event))
+ continue;
+
/* We can skip the events in the first column since they will
draw over this anyway. */
if (event->num_columns > 0 && event->start_row_or_col == 0) {
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index c4d30d6e8f..f622b8252b 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -93,8 +93,15 @@ day_view_top_item_draw_triangle (EDayViewTopItem *top_item,
if (h % 2 == 0)
c1--;
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
+
+ if (!is_comp_data_valid (event))
+ return;
+
cairo_save (cr);
/* Fill it in. */
if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)),
@@ -187,9 +194,15 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
&item_w, &item_h))
return;
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
+ if (!is_comp_data_valid (event))
+ return;
+
style = gtk_widget_get_style (GTK_WIDGET (day_view));
gc = day_view->main_gc;
fg_gc = style->fg_gc[GTK_STATE_NORMAL];
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 3d9985ba08..a171d94d94 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -1526,7 +1526,7 @@ e_day_view_get_text_color (EDayView *day_view, EDayViewEvent *event, GtkWidget *
green = day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].green;
blue = day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND].blue;
- if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), event->comp_data),
+ if (is_comp_data_valid (event) && gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), event->comp_data),
&bg_color)) {
GdkColormap *colormap;
colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
@@ -2009,6 +2009,9 @@ e_day_view_foreach_event_with_uid (EDayView *day_view,
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
+ if (!is_comp_data_valid (event))
+ continue;
+
u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (uid && !strcmp (uid, u)) {
if (!(*callback) (day_view, day, event_num, data))
@@ -2023,6 +2026,9 @@ e_day_view_foreach_event_with_uid (EDayView *day_view,
event = &g_array_index (day_view->long_events,
EDayViewEvent, event_num);
+ if (!is_comp_data_valid (event))
+ continue;
+
u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
if (!(*callback) (day_view, E_DAY_VIEW_LONG_EVENT, event_num, data))
@@ -2044,12 +2050,19 @@ e_day_view_remove_event_cb (EDayView *day_view,
day, event_num);
#endif
- if (day == E_DAY_VIEW_LONG_EVENT)
+ if (day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return TRUE;
+
event = &g_array_index (day_view->long_events,
EDayViewEvent, event_num);
- else
+ } else {
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return TRUE;
+
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
+ }
if (!event)
return TRUE;
@@ -2069,7 +2082,8 @@ e_day_view_remove_event_cb (EDayView *day_view,
if (event->canvas_item)
gtk_object_destroy (GTK_OBJECT (event->canvas_item));
- g_object_unref (event->comp_data);
+ if (is_comp_data_valid (event))
+ g_object_unref (event->comp_data);
event->comp_data = NULL;
if (day == E_DAY_VIEW_LONG_EVENT) {
@@ -2093,6 +2107,9 @@ set_text_as_bold (EDayViewEvent *event)
gchar *address;
ECalComponentAttendee *at = NULL;
+ if (!is_comp_data_valid (event))
+ return;
+
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
address = itip_get_comp_attendee (comp, event->comp_data->client);
@@ -2131,10 +2148,13 @@ e_day_view_update_event_label (EDayView *day_view,
gchar *text;
gint interval;
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent, event_num);
/* If the event isn't visible just return. */
- if (!event->canvas_item)
+ if (!event->canvas_item || !is_comp_data_valid (event))
return;
summary = icalcomponent_get_summary (event->comp_data->icalcomp);
@@ -2182,11 +2202,14 @@ e_day_view_update_long_event_label (EDayView *day_view,
const gchar *summary;
gboolean free_text = FALSE;
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
/* If the event isn't visible just return. */
- if (!event->canvas_item)
+ if (!event->canvas_item || !is_comp_data_valid (event))
return;
summary = e_calendar_view_get_icalcomponent_summary (event->comp_data->client, event->comp_data->icalcomp, &free_text);
@@ -2271,6 +2294,9 @@ e_day_view_find_event_from_uid (EDayView *day_view,
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
+ if (!is_comp_data_valid (event))
+ continue;
+
if (event->comp_data->client != client)
continue;
@@ -2299,6 +2325,9 @@ e_day_view_find_event_from_uid (EDayView *day_view,
event = &g_array_index (day_view->long_events,
EDayViewEvent, event_num);
+ if (!is_comp_data_valid (event))
+ continue;
+
if (event->comp_data->client != client)
continue;
@@ -3424,6 +3453,9 @@ e_day_view_on_long_event_button_press (EDayView *day_view,
} else if (event->button == 3) {
EDayViewEvent *e;
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return TRUE;
+
e = &g_array_index (day_view->long_events, EDayViewEvent, event_num);
e_day_view_set_selected_time_range_in_top_visible (day_view, e->start, e->end);
@@ -3462,6 +3494,9 @@ e_day_view_on_event_button_press (EDayView *day_view,
} else if (event->button == 3) {
EDayViewEvent *e;
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return TRUE;
+
e = &g_array_index (day_view->events[day], EDayViewEvent, event_num);
e_day_view_set_selected_time_range_visible (day_view, e->start, e->end);
@@ -3488,9 +3523,15 @@ e_day_view_on_long_event_click (EDayView *day_view,
gint start_day, end_day, day;
gint item_x, item_y, item_w, item_h;
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
+ if (!is_comp_data_valid (event))
+ return;
+
/* Ignore clicks on the EText while editing. */
if (pos == E_CALENDAR_VIEW_POS_EVENT
&& E_TEXT (event->canvas_item)->editing) {
@@ -3563,9 +3604,15 @@ e_day_view_on_event_click (EDayView *day_view,
GdkWindow *window;
gint tmp_day, row, start_row;
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+ if (!is_comp_data_valid (event))
+ return;
+
/* Ignore clicks on the EText while editing. */
if (pos == E_CALENDAR_VIEW_POS_EVENT
&& E_TEXT (event->canvas_item)->editing) {
@@ -3639,12 +3686,22 @@ e_day_view_on_event_double_click (EDayView *day_view,
EDayViewEvent *event;
icalproperty *attendee_prop = NULL;
- if (day == -1)
+ if (day == -1) {
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
- else
+ } else {
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+ }
+
+ if (!is_comp_data_valid (event))
+ return;
attendee_prop = icalcomponent_get_first_property (event->comp_data->icalcomp, ICAL_ATTENDEE_PROPERTY);
@@ -3686,23 +3743,37 @@ e_day_view_get_selected_events (ECalendarView *cal_view)
g_return_val_if_fail (E_IS_DAY_VIEW (day_view), NULL);
if (day_view->editing_event_num != -1) {
- if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT)
+ if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, day_view->editing_event_num))
+ return NULL;
+
event = &g_array_index (day_view->long_events,
EDayViewEvent,
day_view->editing_event_num);
- else
+ } else {
+ if (!is_array_index_in_bounds (day_view->events[day_view->editing_event_day], day_view->editing_event_num))
+ return NULL;
+
event = &g_array_index (day_view->events[day_view->editing_event_day],
EDayViewEvent,
day_view->editing_event_num);
+ }
} else if (day_view->popup_event_num != -1) {
- if (day_view->popup_event_day == E_DAY_VIEW_LONG_EVENT)
+ if (day_view->popup_event_day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, day_view->popup_event_num))
+ return NULL;
+
event = &g_array_index (day_view->long_events,
EDayViewEvent,
day_view->popup_event_num);
- else
+ } else {
+ if (!is_array_index_in_bounds (day_view->events[day_view->popup_event_day], day_view->popup_event_num))
+ return NULL;
+
event = &g_array_index (day_view->events[day_view->popup_event_day],
EDayViewEvent,
day_view->popup_event_num);
+ }
}
if (event)
@@ -3850,9 +3921,13 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget,
pos = e_day_view_convert_position_in_top_canvas (day_view,
canvas_x, canvas_y,
&day, &event_num);
- if (event_num != -1)
+ if (event_num != -1) {
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return FALSE;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
+ }
if (day_view->selection_is_being_dragged) {
e_day_view_update_selection (day_view, day, -1);
@@ -3865,9 +3940,15 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget,
} else if (day_view->pressed_event_day == E_DAY_VIEW_LONG_EVENT) {
GtkTargetList *target_list;
+ if (!is_array_index_in_bounds (day_view->long_events, day_view->pressed_event_num))
+ return FALSE;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
day_view->pressed_event_num);
+ if (!is_comp_data_valid (event))
+ return FALSE;
+
if (!e_cal_util_component_has_recurrences (event->comp_data->icalcomp)
&& (abs (canvas_x - day_view->drag_event_x)
> E_DAY_VIEW_DRAG_START_OFFSET
@@ -3895,7 +3976,7 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget,
cursor = day_view->normal_cursor;
/* Recurring events can't be resized. */
- if (event && !e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) {
+ if (event && is_comp_data_valid (event) && !e_cal_util_component_has_recurrences (event->comp_data->icalcomp)) {
switch (pos) {
case E_CALENDAR_VIEW_POS_LEFT_EDGE:
case E_CALENDAR_VIEW_POS_RIGHT_EDGE:
@@ -3955,9 +4036,13 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget,
canvas_x, canvas_y,
&day, &row,
&event_num);
- if (event_num != -1)
+ if (event_num != -1) {
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return FALSE;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+ }
if (day_view->selection_is_being_dragged) {
if (pos != E_CALENDAR_VIEW_POS_OUTSIDE) {
@@ -4004,7 +4089,7 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget,
cursor = day_view->normal_cursor;
/* Check if the event is editable and client is not readonly while changing the cursor */
- if (event && event->is_editable && e_cal_is_read_only (event->comp_data->client, &read_only, NULL) && !read_only) {
+ if (event && event->is_editable && is_comp_data_valid (event) && e_cal_is_read_only (event->comp_data->client, &read_only, NULL) && !read_only) {
switch (pos) {
case E_CALENDAR_VIEW_POS_LEFT_EDGE:
@@ -4194,10 +4279,14 @@ e_day_view_update_resize (EDayView *day_view,
day = day_view->resize_event_day;
event_num = day_view->resize_event_num;
+
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
- if (event && (!event->is_editable || (e_cal_is_read_only (event->comp_data->client, &read_only, NULL) && read_only))) {
+ if (event && (!event->is_editable || !is_comp_data_valid (event) || (e_cal_is_read_only (event->comp_data->client, &read_only, NULL) && read_only))) {
return;
}
@@ -4241,9 +4330,16 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
gint is_date;
event_num = day_view->resize_event_num;
+
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
+ if (!is_comp_data_valid (event))
+ return;
+
client = event->comp_data->client;
/* We use a temporary copy of the comp since we don't want to
@@ -4352,9 +4448,16 @@ e_day_view_finish_resize (EDayView *day_view)
day = day_view->resize_event_day;
event_num = day_view->resize_event_num;
+
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+ if (!is_comp_data_valid (event))
+ return;
+
client = event->comp_data->client;
/* We use a temporary shallow copy of the ico since we don't want to
@@ -4503,7 +4606,8 @@ e_day_view_free_event_array (EDayView *day_view,
if (event->canvas_item)
gtk_object_destroy (GTK_OBJECT (event->canvas_item));
- g_object_unref (event->comp_data);
+ if (is_comp_data_valid (event))
+ g_object_unref (event->comp_data);
}
g_array_set_size (array, 0);
@@ -4716,6 +4820,9 @@ e_day_view_reshape_long_event (EDayView *day_view,
PangoContext *pango_context;
PangoLayout *layout;
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
@@ -4730,6 +4837,9 @@ e_day_view_reshape_long_event (EDayView *day_view,
return;
}
+ if (!is_comp_data_valid (event))
+ return;
+
/* Take off the border and padding. */
item_x += E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD;
item_w -= (E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH + E_DAY_VIEW_LONG_EVENT_X_PAD) * 2;
@@ -4875,6 +4985,10 @@ e_day_view_reshape_day_events (EDayView *day_view,
e_day_view_reshape_day_event (day_view, day, event_num);
event = &g_array_index (day_view->events[day], EDayViewEvent, event_num);
+
+ if (!is_comp_data_valid (event))
+ continue;
+
current_comp_string = icalcomponent_as_ical_string_r (event->comp_data->icalcomp);
if (day_view->last_edited_comp_string == NULL) {
g_free (current_comp_string);
@@ -4899,6 +5013,9 @@ e_day_view_reshape_day_event (EDayView *day_view,
gint item_x, item_y, item_w, item_h;
gint num_icons, icons_offset;
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
@@ -4920,9 +5037,9 @@ e_day_view_reshape_day_event (EDayView *day_view,
draw them on top of the resize rect. */
icons_offset = 0;
num_icons = 0;
- if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_NONE
+ if (is_comp_data_valid (event) && (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_NONE
|| day_view->resize_event_day != day
- || day_view->resize_event_num != event_num) {
+ || day_view->resize_event_num != event_num)) {
ECalComponent *comp;
comp = e_cal_component_new ();
@@ -5991,13 +6108,22 @@ e_day_view_start_editing_event (EDayView *day_view,
return;
if (day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
} else {
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
}
+ if (!is_comp_data_valid (event))
+ return;
+
if (!e_cal_is_read_only (event->comp_data->client, &read_only, NULL) || read_only)
return;
@@ -6069,10 +6195,20 @@ cancel_editing (EDayView *day_view)
g_return_if_fail (day != -1);
- if (day == E_DAY_VIEW_LONG_EVENT)
+ if (day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent, event_num);
- else
+ } else {
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent, event_num);
+ }
+
+ if (!is_comp_data_valid (event))
+ return;
/* Reset the text to what was in the component */
@@ -6091,9 +6227,15 @@ tooltip_get_view_event (EDayView *day_view, gint day, gint event_num)
EDayViewEvent *pevent;
if (day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return NULL;
+
pevent = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
} else {
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return NULL;
+
pevent = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
}
@@ -6310,6 +6452,9 @@ e_day_view_event_move (ECalendarView *cal_view, ECalViewMoveDirection direction)
if ((day == -1) || (day == E_DAY_VIEW_LONG_EVENT))
return FALSE;
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return FALSE;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
day_view->resize_event_day = day;
@@ -6386,8 +6531,16 @@ e_day_view_change_event_time (EDayView *day_view, time_t start_dt, time_t end_dt
day = day_view->editing_event_day;
event_num = day_view->editing_event_num;
+
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+
+ if (!is_comp_data_valid (event))
+ return;
+
client = event->comp_data->client;
/* We use a temporary shallow copy of the ico since we don't want to
@@ -6461,6 +6614,10 @@ e_day_view_change_event_end_time_up (EDayView *day_view)
event_num = day_view->editing_event_num;
if ((day == -1) || (day == E_DAY_VIEW_LONG_EVENT))
return;
+
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
day_view->resize_event_day = day;
@@ -6491,6 +6648,10 @@ e_day_view_change_event_end_time_down (EDayView *day_view)
event_num = day_view->editing_event_num;
if ((day == -1) || (day == E_DAY_VIEW_LONG_EVENT))
return;
+
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
day_view->resize_event_day = day;
@@ -6600,14 +6761,23 @@ e_day_view_on_editing_stopped (EDayView *day_view,
return;
if (day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
} else {
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
}
+ if (!is_comp_data_valid (event))
+ return;
+
/* Reset the edit fields. */
day_view->editing_event_day = -1;
day_view->editing_event_num = -1;
@@ -6956,6 +7126,9 @@ e_day_view_get_event_rows (EDayView *day_view,
g_return_val_if_fail (day < E_DAY_VIEW_LONG_EVENT, FALSE);
g_return_val_if_fail (event_num >= 0, FALSE);
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return FALSE;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
start_row = event->start_minute / day_view->mins_per_row;
@@ -6980,6 +7153,9 @@ e_day_view_get_event_position (EDayView *day_view,
EDayViewEvent *event;
gint start_row, end_row, cols_in_row, start_col, num_columns;
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return FALSE;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
@@ -7034,6 +7210,9 @@ e_day_view_get_long_event_position (EDayView *day_view,
{
EDayViewEvent *event;
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return FALSE;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
@@ -7304,6 +7483,9 @@ e_day_view_update_top_canvas_drag (EDayView *day_view,
num_days = 1;
if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, day_view->drag_event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
day_view->drag_event_num);
row = event->start_row_or_col + 1;
@@ -7320,6 +7502,9 @@ e_day_view_update_top_canvas_drag (EDayView *day_view,
day = MIN (day, day_view->days_shown - num_days);
} else if (day_view->drag_event_day != -1) {
+ if (!is_array_index_in_bounds (day_view->events[day_view->drag_event_day], day_view->drag_event_num))
+ return;
+
event = &g_array_index (day_view->events[day_view->drag_event_day],
EDayViewEvent,
day_view->drag_event_num);
@@ -7367,7 +7552,7 @@ e_day_view_update_top_canvas_drag (EDayView *day_view,
& GNOME_CANVAS_ITEM_VISIBLE)) {
const gchar *summary;
- if (event) {
+ if (event && is_comp_data_valid (event)) {
summary = icalcomponent_get_summary (event->comp_data->icalcomp);
text = g_strdup (summary);
} else {
@@ -7460,9 +7645,15 @@ e_day_view_update_main_canvas_drag (EDayView *day_view,
num_rows = 1;
if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, day_view->drag_event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
day_view->drag_event_num);
} else if (day_view->drag_event_day != -1) {
+ if (!is_array_index_in_bounds (day_view->events[day_view->drag_event_day], day_view->drag_event_num))
+ return;
+
event = &g_array_index (day_view->events[day_view->drag_event_day],
EDayViewEvent,
day_view->drag_event_num);
@@ -7526,7 +7717,7 @@ e_day_view_update_main_canvas_drag (EDayView *day_view,
if (!(day_view->drag_item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)) {
const gchar *summary;
- if (event) {
+ if (event && is_comp_data_valid (event)) {
summary = icalcomponent_get_summary (event->comp_data->icalcomp);
text = g_strdup (summary);
} else {
@@ -7590,12 +7781,19 @@ e_day_view_on_drag_begin (GtkWidget *widget,
g_return_if_fail (day != -1);
g_return_if_fail (event_num != -1);
- if (day == E_DAY_VIEW_LONG_EVENT)
+ if (day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
- else
+ } else {
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
+ }
/* Hide the text item, since it will be shown in the special drag
items. */
@@ -7619,10 +7817,16 @@ e_day_view_on_drag_end (GtkWidget *widget,
return;
if (day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
event_num);
gtk_widget_queue_draw (day_view->top_canvas);
} else {
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
gtk_widget_queue_draw (day_view->main_canvas);
@@ -7655,12 +7859,22 @@ e_day_view_on_drag_data_get (GtkWidget *widget,
g_return_if_fail (day != -1);
g_return_if_fail (event_num != -1);
- if (day == E_DAY_VIEW_LONG_EVENT)
+ if (day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, event_num))
+ return;
+
event = &g_array_index (day_view->long_events,
EDayViewEvent, event_num);
- else
+ } else {
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
+ return;
+
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
+ }
+
+ if (!is_comp_data_valid (event))
+ return;
vcal = e_cal_util_new_top_level ();
e_cal_util_add_timezones_from_component (
@@ -7742,8 +7956,15 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
end_offset = 0;
if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, day_view->drag_event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
day_view->drag_event_num);
+
+ if (!is_comp_data_valid (event))
+ return;
+
day -= day_view->drag_event_offset;
day = MAX (day, 0);
@@ -7759,9 +7980,15 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
start_offset = event->start_minute;
end_offset = event->end_minute;
} else {
+ if (!is_array_index_in_bounds (day_view->events[day_view->drag_event_day], day_view->drag_event_num))
+ return;
+
event = &g_array_index (day_view->events[day_view->drag_event_day],
EDayViewEvent,
day_view->drag_event_num);
+
+ if (!is_comp_data_valid (event))
+ return;
}
client = event->comp_data->client;
@@ -7973,12 +8200,25 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
end_offset = 0;
if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, day_view->drag_event_num))
+ return;
+
event = &g_array_index (day_view->long_events, EDayViewEvent,
day_view->drag_event_num);
+
+ if (!is_comp_data_valid (event))
+ return;
} else {
+ if (!is_array_index_in_bounds (day_view->events[day_view->drag_event_day], day_view->drag_event_num))
+ return;
+
event = &g_array_index (day_view->events[day_view->drag_event_day],
EDayViewEvent,
day_view->drag_event_num);
+
+ if (!is_comp_data_valid (event))
+ return;
+
row -= day_view->drag_event_offset;
/* Calculate time offset from start row. */
@@ -8233,10 +8473,16 @@ e_day_view_paste_text (ECalendarView *cal_view)
return;
if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT) {
+ if (!is_array_index_in_bounds (day_view->long_events, day_view->editing_event_num))
+ return;
+
event = &g_array_index (day_view->long_events,
EDayViewEvent,
day_view->editing_event_num);
} else {
+ if (!is_array_index_in_bounds (day_view->events[day_view->editing_event_day], day_view->editing_event_num))
+ return;
+
event = &g_array_index (day_view->events[day_view->editing_event_day],
EDayViewEvent,
day_view->editing_event_num);
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index 5d3fefaaee..ba44b7a24a 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -132,13 +132,22 @@ week_view_event_item_double_click (EWeekViewEventItem *event_item,
week_view = E_WEEK_VIEW (parent);
+ if (!is_array_index_in_bounds (week_view->events, event_item->priv->event_num))
+ return TRUE;
+
event = &g_array_index (
week_view->events, EWeekViewEvent,
event_item->priv->event_num);
+ if (!is_comp_data_valid (event))
+ return TRUE;
+
if (week_view->editing_event_num >= 0) {
EWeekViewEvent *editing;
+ if (!is_array_index_in_bounds (week_view->events, week_view->editing_event_num))
+ return TRUE;
+
editing = &g_array_index (
week_view->events, EWeekViewEvent,
week_view->editing_event_num);
@@ -147,6 +156,7 @@ week_view_event_item_double_click (EWeekViewEventItem *event_item,
* on the component, which is not on the server. */
if (editing && event &&
editing->comp_data == event->comp_data &&
+ is_comp_data_valid (editing) &&
(!event->comp_data ||
!is_icalcomp_on_the_server (
event->comp_data->icalcomp,
@@ -182,8 +192,15 @@ week_view_event_item_button_press (EWeekViewEventItem *event_item,
week_view = E_WEEK_VIEW (parent);
+ if (!is_array_index_in_bounds (week_view->events, event_item->priv->event_num))
+ return FALSE;
+
event = &g_array_index (week_view->events, EWeekViewEvent,
event_item->priv->event_num);
+
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + event_item->priv->span_num))
+ return FALSE;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + event_item->priv->span_num);
@@ -390,8 +407,15 @@ week_view_event_item_draw_icons (EWeekViewEventItem *event_item,
parent = gtk_widget_get_parent (GTK_WIDGET (canvas));
week_view = E_WEEK_VIEW (parent);
+ if (!is_array_index_in_bounds (week_view->events, event_item->priv->event_num))
+ return;
+
event = &g_array_index (week_view->events, EWeekViewEvent,
event_item->priv->event_num);
+
+ if (!is_comp_data_valid (event))
+ return;
+
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (
comp, icalcomponent_new_clone (event->comp_data->icalcomp));
@@ -510,9 +534,15 @@ week_view_event_item_draw_triangle (EWeekViewEventItem *event_item,
parent = gtk_widget_get_parent (GTK_WIDGET (canvas));
week_view = E_WEEK_VIEW (parent);
+ if (!is_array_index_in_bounds (week_view->events, event_item->priv->event_num))
+ return;
+
event = &g_array_index (week_view->events, EWeekViewEvent,
event_item->priv->event_num);
+ if (!is_comp_data_valid (event))
+ return;
+
cr = gdk_cairo_create (drawable);
points[0].x = x;
@@ -716,13 +746,22 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item,
g_return_if_fail (event_item->priv->event_num < week_view->events->len);
+ if (!is_array_index_in_bounds (week_view->events, event_item->priv->event_num))
+ return;
+
event = &g_array_index (week_view->events, EWeekViewEvent,
event_item->priv->event_num);
+ if (!is_comp_data_valid (event))
+ return;
+
g_return_if_fail (
event->spans_index + event_item->priv->span_num <
week_view->spans->len);
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + event_item->priv->span_num))
+ return;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + event_item->priv->span_num);
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 5e850f53ab..173b79bbd5 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -1043,7 +1043,7 @@ e_week_view_get_text_color (EWeekView *week_view, EWeekViewEvent *event, GtkWidg
green = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].green;
blue = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND].blue;
- if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)), event->comp_data),
+ if (is_comp_data_valid (event) && gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)), event->comp_data),
&bg_color)) {
GdkColormap *colormap;
colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view));
@@ -1520,9 +1520,16 @@ e_week_view_focus (GtkWidget *widget, GtkDirectionType direction)
EWeekViewEventSpan *span;
gint current_day;
+ if (!is_array_index_in_bounds (week_view->events, new_event_num))
+ break;
+
event = &g_array_index (week_view->events,
EWeekViewEvent,
new_event_num);
+
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + new_span_num))
+ break;
+
span = &g_array_index (week_view->spans,
EWeekViewEventSpan,
event->spans_index + new_span_num);
@@ -1552,9 +1559,15 @@ e_week_view_get_selected_events (ECalendarView *cal_view)
g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), NULL);
if (week_view->editing_event_num != -1) {
+ if (!is_array_index_in_bounds (week_view->events, week_view->editing_event_num))
+ return NULL;
+
event = &g_array_index (week_view->events, EWeekViewEvent,
week_view->editing_event_num);
} else if (week_view->popup_event_num != -1) {
+ if (!is_array_index_in_bounds (week_view->events, week_view->popup_event_num))
+ return NULL;
+
event = &g_array_index (week_view->events, EWeekViewEvent,
week_view->popup_event_num);
}
@@ -2129,6 +2142,9 @@ set_text_as_bold (EWeekViewEvent *event, EWeekViewEventSpan *span)
gchar *address;
ECalComponentAttendee *at = NULL;
+ if (!is_comp_data_valid (event))
+ return;
+
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
address = itip_get_comp_attendee (comp, event->comp_data->client);
@@ -2174,6 +2190,9 @@ e_week_view_foreach_event_with_uid (EWeekView *week_view,
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
+ if (!is_comp_data_valid (event))
+ continue;
+
u = icalcomponent_get_uid (event->comp_data->icalcomp);
if (u && !strcmp (uid, u)) {
if (!(*callback) (week_view, event_num, data))
@@ -2191,6 +2210,9 @@ e_week_view_remove_event_cb (EWeekView *week_view,
EWeekViewEventSpan *span;
gint span_num;
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return TRUE;
+
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
if (!event)
return TRUE;
@@ -2203,13 +2225,17 @@ e_week_view_remove_event_cb (EWeekView *week_view,
if (week_view->popup_event_num == event_num)
week_view->popup_event_num = -1;
- g_object_unref (event->comp_data);
+ if (is_comp_data_valid (event))
+ g_object_unref (event->comp_data);
event->comp_data = NULL;
if (week_view->spans) {
/* We leave the span elements in the array, but set the canvas item
pointers to NULL. */
for (span_num = 0; span_num < event->num_spans; span_num++) {
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + span_num))
+ break;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + span_num);
@@ -2307,6 +2333,9 @@ e_week_view_get_span_position (EWeekView *week_view,
g_return_val_if_fail (span_num < event->num_spans, FALSE);
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + span_num))
+ return FALSE;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + span_num);
@@ -2349,7 +2378,14 @@ ewv_pass_gdkevent_to_etext (EWeekView *week_view, GdkEvent *gevent)
EWeekViewEvent *event;
EWeekViewEventSpan *span;
+ if (!is_array_index_in_bounds (week_view->events, week_view->editing_event_num))
+ return FALSE;
+
event = &g_array_index (week_view->events, EWeekViewEvent, week_view->editing_event_num);
+
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + week_view->editing_span_num))
+ return FALSE;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + week_view->editing_span_num);
if (span->text_item && E_IS_TEXT (span->text_item)) {
@@ -2660,7 +2696,9 @@ e_week_view_free_events (EWeekView *week_view)
for (event_num = 0; event_num < week_view->events->len; event_num++) {
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
- g_object_unref (event->comp_data);
+
+ if (is_comp_data_valid (event))
+ g_object_unref (event->comp_data);
}
g_array_set_size (week_view->events, 0);
@@ -2842,6 +2880,9 @@ e_week_view_reshape_events (EWeekView *week_view)
for (event_num = 0; event_num < week_view->events->len; event_num++) {
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
+ if (!is_comp_data_valid (event))
+ continue;
+
for (span_num = 0; span_num < event->num_spans; span_num++) {
gchar *current_comp_string;
@@ -2852,6 +2893,12 @@ e_week_view_reshape_events (EWeekView *week_view)
current_comp_string = icalcomponent_as_ical_string_r (event->comp_data->icalcomp);
if (strncmp (current_comp_string, week_view->last_edited_comp_string,50) == 0) {
EWeekViewEventSpan *span;
+
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + span_num)) {
+ g_free (current_comp_string);
+ continue;
+ }
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + span_num);
e_canvas_item_grab_focus (span->text_item, TRUE);
g_free (week_view->last_edited_comp_string);
@@ -2900,6 +2947,9 @@ tooltip_get_view_event (EWeekView *week_view, gint day, gint event_num)
{
EWeekViewEvent *pevent;
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return NULL;
+
pevent = &g_array_index (week_view->events, EWeekViewEvent, event_num);
return pevent;
@@ -2998,7 +3048,17 @@ e_week_view_reshape_event_span (EWeekView *week_view,
PangoFontMetrics *font_metrics;
PangoLayout *layout;
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return;
+
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
+
+ if (!is_comp_data_valid (event))
+ return;
+
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + span_num))
+ return;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + span_num);
comp = e_cal_component_new ();
@@ -3268,7 +3328,17 @@ e_week_view_start_editing_event (EWeekView *week_view,
&& span_num == week_view->editing_span_num)
return TRUE;
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return FALSE;
+
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
+
+ if (!is_comp_data_valid (event))
+ return FALSE;
+
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + span_num))
+ return FALSE;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + span_num);
@@ -3280,7 +3350,12 @@ e_week_view_start_editing_event (EWeekView *week_view,
return FALSE;
if (week_view->editing_event_num >= 0) {
- EWeekViewEvent *editing = &g_array_index (week_view->events, EWeekViewEvent, week_view->editing_event_num);
+ EWeekViewEvent *editing;
+
+ if (!is_array_index_in_bounds (week_view->events, week_view->editing_event_num))
+ return FALSE;
+
+ editing = &g_array_index (week_view->events, EWeekViewEvent, week_view->editing_event_num);
/* do not change to other part of same component - the event is spread into more days */
if (editing && event && editing->comp_data == event->comp_data)
@@ -3317,6 +3392,10 @@ e_week_view_start_editing_event (EWeekView *week_view,
}
g_return_val_if_fail (event_num >= 0, FALSE);
}
+
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + span_num))
+ return FALSE;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + span_num);
/* Try to move the cursor to the end of the text. */
@@ -3361,7 +3440,17 @@ cancel_editing (EWeekView *week_view)
g_return_if_fail (event_num != -1);
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return;
+
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
+
+ if (!is_comp_data_valid (event))
+ return;
+
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + span_num))
+ return;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + span_num);
/* Reset the text to what was in the component */
@@ -3417,9 +3506,15 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item,
&event_num, &span_num))
return FALSE;
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return FALSE;
+
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
+ if (!is_comp_data_valid (event))
+ return FALSE;
+
/* if we started to editing new item on the canvas, then do not open editing dialog until it's saved,
because the save of the event recalculates event numbers and you can edit different one */
if (!is_icalcomp_on_the_server (event->comp_data->icalcomp, event->comp_data->client))
@@ -3446,6 +3541,9 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item,
return FALSE;
}
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return FALSE;
+
e = &g_array_index (week_view->events, EWeekViewEvent, event_num);
if (!gtk_widget_has_focus (GTK_WIDGET (week_view)))
@@ -3583,8 +3681,14 @@ static gboolean e_week_view_event_move (ECalendarView *cal_view, ECalViewMoveDir
if (event_num == -1)
return FALSE;
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return FALSE;
+
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
+ if (!is_comp_data_valid (event))
+ return FALSE;
+
end_dt = event->end;
start_time = icalcomponent_get_dtstart (event->comp_data->icalcomp);
end_time = icalcomponent_get_dtend (event->comp_data->icalcomp);
@@ -3711,7 +3815,14 @@ e_week_view_change_event_time (EWeekView *week_view, time_t start_dt, time_t end
if (event_num == -1)
return;
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return;
+
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
+
+ if (!is_comp_data_valid (event))
+ return;
+
client = event->comp_data->client;
/* We use a temporary shallow copy of the ico since we don't want to
@@ -3818,7 +3929,17 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
if (event_num == -1)
return;
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return;
+
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
+
+ if (!is_comp_data_valid (event))
+ return;
+
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + span_num))
+ return;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + span_num);
@@ -3967,6 +4088,9 @@ e_week_view_find_event_from_item (EWeekView *week_view,
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
for (span_num = 0; span_num < event->num_spans; span_num++) {
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + span_num))
+ continue;
+
span = &g_array_index (week_view->spans,
EWeekViewEventSpan,
event->spans_index + span_num);
@@ -4009,6 +4133,9 @@ e_week_view_find_event_from_uid (EWeekView *week_view,
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
+ if (!is_comp_data_valid (event))
+ continue;
+
if (event->comp_data->client != client)
continue;
@@ -4040,10 +4167,16 @@ e_week_view_is_one_day_event (EWeekView *week_view,
EWeekViewEvent *event;
EWeekViewEventSpan *span;
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return FALSE;
+
event = &g_array_index (week_view->events, EWeekViewEvent, event_num);
if (event->num_spans != 1)
return FALSE;
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index))
+ return FALSE;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index);
@@ -4172,8 +4305,15 @@ e_week_view_add_new_event_in_selected_range (EWeekView *week_view, const gchar *
return FALSE;
}
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return FALSE;
+
wvevent = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
+
+ if (!is_array_index_in_bounds (week_view->spans, wvevent->spans_index + 0))
+ return FALSE;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
wvevent->spans_index + 0);
@@ -4553,8 +4693,15 @@ e_week_view_paste_text (ECalendarView *cal_view)
!e_week_view_add_new_event_in_selected_range (week_view, NULL))
return;
+ if (!is_array_index_in_bounds (week_view->events, week_view->editing_event_num))
+ return;
+
event = &g_array_index (week_view->events, EWeekViewEvent,
week_view->editing_event_num);
+
+ if (!is_array_index_in_bounds (week_view->spans, event->spans_index + week_view->editing_span_num))
+ return;
+
span = &g_array_index (week_view->spans, EWeekViewEventSpan,
event->spans_index + week_view->editing_span_num);
diff --git a/calendar/gui/ea-cal-view-event.c b/calendar/gui/ea-cal-view-event.c
index 5b4bcc7e1b..b2bdc5c4b3 100644
--- a/calendar/gui/ea-cal-view-event.c
+++ b/calendar/gui/ea-cal-view-event.c
@@ -198,9 +198,17 @@ ea_cal_view_event_new (GObject *obj)
&event_num,
&span_num))
return NULL;
+
+ if (!is_array_index_in_bounds (week_view->events, event_num))
+ return NULL;
+
week_view_event = &g_array_index (week_view->events,
EWeekViewEvent,
event_num);
+
+ if (!is_array_index_in_bounds (week_view->spans, week_view_event->spans_index))
+ return NULL;
+
/* get the first span */
event_span = &g_array_index (week_view->spans,
EWeekViewEventSpan,
@@ -269,6 +277,8 @@ ea_cal_view_event_get_name (AtkObject *accessible)
if (!g_obj || !E_IS_TEXT (g_obj))
return NULL;
event = ea_calendar_helpers_get_cal_view_event_from (GNOME_CANVAS_ITEM(g_obj));
+ if (!is_comp_data_valid (event))
+ return NULL;
alarm_string = recur_string = meeting_string = "";
if (event && event->comp_data) {
diff --git a/calendar/gui/print.c b/calendar/gui/print.c
index 0b3f8003c9..ab2f784c33 100644
--- a/calendar/gui/print.c
+++ b/calendar/gui/print.c
@@ -1092,6 +1092,9 @@ print_day_long_event (GtkPrintContext *context,
struct tm date_tm;
gdouble red, green, blue;
+ if (!is_comp_data_valid (event))
+ return;
+
/* If the event starts before the first day being printed, draw a
triangle. (Note that I am assuming we are just showing 1 day at
the moment.) */
@@ -1172,6 +1175,9 @@ print_day_event (GtkPrintContext *context, PangoFontDescription *font,
struct tm date_tm;
gdouble red, green, blue;
+ if (!is_comp_data_valid (event))
+ return;
+
if ((event->start_minute >= pdi->end_minute_offset)
|| (event->end_minute <= pdi->start_minute_offset))
return;
@@ -1561,6 +1567,9 @@ print_week_event (GtkPrintContext *context, PangoFontDescription *font,
gdouble red, green, blue;
GdkPixbuf *pixbuf = NULL;
+ if (!is_comp_data_valid (event))
+ return;
+
text = get_summary_with_location (event->comp_data->icalcomp);
for (span_num = 0; span_num < event->num_spans; span_num++) {