From 87c04cfc2ccd7ffea028ee4e1d7a7e5d554ca056 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 29 Jun 2011 23:08:37 +0200 Subject: Add a bit more error checking and do not leak icalcomponent-s --- modules/calendar/e-cal-shell-backend.c | 10 +++++++--- modules/calendar/e-cal-shell-view-private.c | 3 +-- modules/calendar/e-memo-shell-backend.c | 6 +++++- modules/calendar/e-task-shell-backend.c | 10 +++++++--- 4 files changed, 20 insertions(+), 9 deletions(-) (limited to 'modules/calendar') diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c index 8d0c6ef36a..4b2692e420 100644 --- a/modules/calendar/e-cal-shell-backend.c +++ b/modules/calendar/e-cal-shell-backend.c @@ -624,10 +624,14 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend, } comp = e_cal_component_new (); - e_cal_component_set_icalcomponent (comp, icalcomp); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { + g_debug ("%s: Failed to set icalcomp to comp\n", G_STRFUNC); + icalcomponent_free (icalcomp); + icalcomp = NULL; + } - icalprop = icalcomponent_get_first_property ( - icalcomp, ICAL_ATTENDEE_PROPERTY); + icalprop = icalcomp ? icalcomponent_get_first_property ( + icalcomp, ICAL_ATTENDEE_PROPERTY) : NULL; if (icalprop != NULL) flags |= COMP_EDITOR_MEETING; diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index d4cee1a627..0ca3f344ec 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -871,8 +871,7 @@ e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, if (success) { /* Use master object when working * with a recurring event ... */ - icalcomp_clone = - icalcomponent_new_clone (icalcomp); + icalcomp_clone = icalcomponent_new_clone (icalcomp); icalcomponent_free (icalcomp); } else { /* ... or remove the recurrence ID ... */ diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c index 8d39843054..2be78895f6 100644 --- a/modules/calendar/e-memo-shell-backend.c +++ b/modules/calendar/e-memo-shell-backend.c @@ -419,7 +419,11 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend, } comp = e_cal_component_new (); - e_cal_component_set_icalcomponent (comp, icalcomp); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { + g_debug ("%s: Failed to set icalcomp to comp\n", G_STRFUNC); + icalcomponent_free (icalcomp); + icalcomp = NULL; + } if (e_cal_component_has_organizer (comp)) flags |= COMP_EDITOR_IS_SHARED; diff --git a/modules/calendar/e-task-shell-backend.c b/modules/calendar/e-task-shell-backend.c index 768f46fd28..ebee92479b 100644 --- a/modules/calendar/e-task-shell-backend.c +++ b/modules/calendar/e-task-shell-backend.c @@ -419,10 +419,14 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend, } comp = e_cal_component_new (); - e_cal_component_set_icalcomponent (comp, icalcomp); + if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { + g_debug ("%s: Failed to set icalcomp to comp\n", G_STRFUNC); + icalcomponent_free (icalcomp); + icalcomp = NULL; + } - icalprop = icalcomponent_get_first_property ( - icalcomp, ICAL_ATTENDEE_PROPERTY); + icalprop = icalcomp ? icalcomponent_get_first_property ( + icalcomp, ICAL_ATTENDEE_PROPERTY) : NULL; if (icalprop != NULL) flags |= COMP_EDITOR_IS_ASSIGNED; -- cgit v1.2.3