Add a bit more error checking and do not leak icalcomponent-s

This commit is contained in:
Milan Crha
2011-06-29 23:08:37 +02:00
committed by Rodrigo Moya
parent a624e7b483
commit 19307b54bc
9 changed files with 47 additions and 19 deletions

View File

@ -722,7 +722,12 @@ comp_util_sanitize_recurrence_master (ECalComponent *comp,
}
master = e_cal_component_new ();
e_cal_component_set_icalcomponent (master, icalcomp);
if (!e_cal_component_set_icalcomponent (master, icalcomp)) {
icalcomponent_free (icalcomp);
g_object_unref (master);
g_return_if_reached ();
return;
}
/* Compare recur id and start date */
e_cal_component_get_recurid (comp, &rid);
@ -739,6 +744,10 @@ comp_util_sanitize_recurrence_master (ECalComponent *comp,
e_cal_component_get_dtend (comp, &edt);
g_return_if_fail (msdt.value != NULL);
g_return_if_fail (medt.value != NULL);
g_return_if_fail (edt.value != NULL);
sdt.value->year = msdt.value->year;
sdt.value->month = msdt.value->month;
sdt.value->day = msdt.value->day;

View File

@ -43,9 +43,11 @@ calendar_selector_update_single_object (ECalClient *client,
uid = (gchar *) icalcomponent_get_uid (icalcomp);
if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL))
return e_cal_client_modify_object_sync (
client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL);
if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) {
icalcomponent_free (tmp_icalcomp);
return e_cal_client_modify_object_sync (client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL);
}
uid = NULL;
if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL))

View File

@ -2091,6 +2091,8 @@ e_calendar_view_get_icalcomponent_summary (ECalClient *client, icalcomponent *ic
summary = g_strdup_printf ("%s (%d)", summary ? summary : "", dtnow.year - dtstart.year);
*free_text = summary != NULL;
}
icalcomponent_free (item_icalcomp);
}
}

View File

@ -45,9 +45,11 @@ memo_list_selector_update_single_object (ECalClient *client,
uid = (gchar *) icalcomponent_get_uid (icalcomp);
if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL))
return e_cal_client_modify_object_sync (
client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL);
if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) {
icalcomponent_free (tmp_icalcomp);
return e_cal_client_modify_object_sync (client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL);
}
if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL))
return FALSE;

View File

@ -45,9 +45,11 @@ task_list_selector_update_single_object (ECalClient *client,
uid = (gchar *) icalcomponent_get_uid (icalcomp);
if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL))
return e_cal_client_modify_object_sync (
client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL);
if (e_cal_client_get_object_sync (client, uid, NULL, &tmp_icalcomp, NULL, NULL)) {
icalcomponent_free (tmp_icalcomp);
return e_cal_client_modify_object_sync (client, icalcomp, CALOBJ_MOD_ALL, NULL, NULL);
}
if (!e_cal_client_create_object_sync (client, icalcomp, &uid, NULL, NULL))
return FALSE;

View File

@ -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;

View File

@ -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 ... */

View File

@ -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;

View File

@ -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;