From e48c585c945848799ed0489f544644b4e645b4a3 Mon Sep 17 00:00:00 2001 From: Monique Faria Date: Tue, 8 Mar 2016 00:03:42 -0300 Subject: [PATCH] event: fix crash when no end date is given In this commit, we fixed a crash report that occurred when an event had no end date. Events with no end dates are all-day, 1-day length events. But, when an event with no end date set was synchronized with calendar (happened mostly with birthdays), it caused crashes, because the function responsible for getting the end date received NULL. To correct this, we considered that end = start + 1day when no end date is set. With this, the mistake was corrected. Another thing that was correct along with this were two memory leaks, caused by the allocation of both end and start date that were not been freed. https://bugzilla.gnome.org/show_bug.cgi?id=762985 --- src/gcal-event.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gcal-event.c b/src/gcal-event.c index 145d7f94..a3916c21 100644 --- a/src/gcal-event.c +++ b/src/gcal-event.c @@ -222,6 +222,13 @@ gcal_event_set_component_internal (GcalEvent *self, /* Setup end date */ e_cal_component_get_dtend (component, &end); + + if(!end.value) + { + end = start; + end.value->day = start.value->day + 1; + } + date = icaltime_normalize (*end.value); zone_end = get_timezone_from_ical (&end); date_end = g_date_time_new (zone_end, @@ -250,6 +257,9 @@ gcal_event_set_component_internal (GcalEvent *self, g_clear_pointer (&zone_start, g_time_zone_unref); g_clear_pointer (&zone_end, g_time_zone_unref); g_clear_pointer (&description, g_free); + + e_cal_component_free_datetime(&start); + e_cal_component_free_datetime(&end); } }