aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-01-27 19:24:55 +0800
committerMilan Crha <mcrha@redhat.com>2010-01-27 19:24:55 +0800
commit0e06ff46d0cc53ae2108219490c0bb9c7106d33a (patch)
tree9c9db6bbe966ebbe8737023243fc62b5b7ce06c6
parent65305b728467e74a22300be78cbf498fc5213973 (diff)
downloadgsoc2013-evolution-0e06ff46d0cc53ae2108219490c0bb9c7106d33a.tar.gz
gsoc2013-evolution-0e06ff46d0cc53ae2108219490c0bb9c7106d33a.tar.zst
gsoc2013-evolution-0e06ff46d0cc53ae2108219490c0bb9c7106d33a.zip
Bug #607751 - Double free while copying whole calendar
-rw-r--r--calendar/gui/dialogs/copy-source-dialog.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/calendar/gui/dialogs/copy-source-dialog.c b/calendar/gui/dialogs/copy-source-dialog.c
index 20e779a2a7..095d10131d 100644
--- a/calendar/gui/dialogs/copy-source-dialog.c
+++ b/calendar/gui/dialogs/copy-source-dialog.c
@@ -49,6 +49,31 @@ show_error (GtkWindow *parent, const gchar *msg)
gtk_widget_destroy (dialog);
}
+struct ForeachTzidData
+{
+ ECal *source_client;
+ ECal *dest_client;
+};
+
+static void
+add_timezone_to_cal_cb (icalparameter *param, gpointer data)
+{
+ struct ForeachTzidData *ftd = data;
+ icaltimezone *tz = NULL;
+ const gchar *tzid;
+
+ g_return_if_fail (ftd != NULL);
+ g_return_if_fail (ftd->source_client != NULL);
+ g_return_if_fail (ftd->dest_client != NULL);
+
+ tzid = icalparameter_get_tzid (param);
+ if (!tzid || !*tzid)
+ return;
+
+ if (e_cal_get_timezone (ftd->source_client, tzid, &tz, NULL) && tz)
+ e_cal_add_timezone (ftd->dest_client, tz, NULL);
+}
+
static gboolean
copy_source (CopySourceDialogData *csdd)
{
@@ -84,8 +109,11 @@ copy_source (CopySourceDialogData *csdd)
} else {
if (e_cal_get_object_list (source_client, "#t", &obj_list, NULL)) {
GList *l;
- const gchar *uid;
icalcomponent *icalcomp;
+ struct ForeachTzidData ftd;
+
+ ftd.source_client = source_client;
+ ftd.dest_client = dest_client;
for (l = obj_list; l != NULL; l = l->next) {
/* FIXME: process recurrences */
@@ -95,8 +123,23 @@ copy_source (CopySourceDialogData *csdd)
e_cal_modify_object (dest_client, l->data, CALOBJ_MOD_ALL, NULL);
icalcomponent_free (icalcomp);
} else {
- e_cal_create_object (dest_client, l->data, (gchar **) &uid, NULL);
- g_free ((gpointer) uid);
+ gchar *uid = NULL;
+ GError *error = NULL;
+
+ icalcomp = l->data;
+
+ /* add timezone information from source ECal to the destination ECal */
+ icalcomponent_foreach_tzid (icalcomp, add_timezone_to_cal_cb, &ftd);
+
+ if (e_cal_create_object (dest_client, icalcomp, &uid, &error)) {
+ g_free (uid);
+ } else {
+ if (error) {
+ show_error (NULL, error->message);
+ g_error_free (error);
+ }
+ break;
+ }
}
}