[evolution-patches] seek review the patch for #51052



Hello JPR and Rodrigo:
Could you review the patch for the bug 51052?

I Checked the src code of evolution. In the prepare_events and
prepare_tasks of calendar/importers/icalendar-importer.c
I found a error that caused this bug. please see the comments inline.

       iter = icalcomponent_begin_component (icalcomp,
ICAL_ANY_COMPONENT);
       while ((subcomp = icalcompiter_deref (&iter)) != NULL) {
               icalcomponent_kind child_kind = icalcomponent_isa
(subcomp);
               if (child_kind != ICAL_VEVENT_COMPONENT
                   && child_kind != ICAL_VTIMEZONE_COMPONENT) {

                       icalcomponent_remove_component (icalcomp,
subcomp);


//                      the above line will break the link.
//			for example, A-->B-->C-->D , If you remove
//			C, when call icalcompiter_next (&iter); iter
// will point to C. and the C->next is null and // so, the link break.


//			That caused the  return value (vetodo) only have
// one component. and the other components(tasks) // be leaked.

                       if (child_kind == ICAL_VTODO_COMPONENT)
                               vtodos = g_list_prepend (vtodos,
subcomp);
                       else
                               icalcomponent_free (subcomp);

               }

               icalcompiter_next (&iter);
       }

Thanks
jack



Description of Problem:


Steps to reproduce the problem:
1. set the task default folder on the local tasks.
2. import a calendar file to the sunone calendar server with N events
and M
tasks.
3. N the events was imported to SunOne calendar folder correctly.  M the
tasks was imported to the local tasks(default tasks folder) correctly.

4. But M-1 tasks was imported to the sunone tasks by mistake because of
a
logical error in the evolution src code.
Actual Results:
No tasks was imported to the sunone tasks.

Expected Results:
M-1 tasks was imported to the sunone tasks by mistake.

How often does this happen? Always

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1802.2.36
diff -u -r1.1802.2.36 ChangeLog
--- ChangeLog	3 Nov 2003 02:58:28 -0000	1.1802.2.36
+++ ChangeLog	17 Nov 2003 04:07:20 -0000
@@ -1,3 +1,12 @@
+2003-11-17  Jack Jia <jack jia sun com>
+
+	Fix for #51052.
+
+	* importers/icalendar-importer.c (prepare_events):
+	call icalcompiter_next to move the pointer to the next before
+	removing a component avoid breaking the link.
+	* importers/icalendar-importer.c (prepare_tasks): ditto.
+
 2003-10-31  Harry Lu <harry lu sun com>
 
 	Fix for #50387.
Index: importers/icalendar-importer.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/importers/icalendar-importer.c,v
retrieving revision 1.20.4.1
diff -u -r1.20.4.1 icalendar-importer.c
--- importers/icalendar-importer.c	3 Nov 2003 02:58:29 -0000	1.20.4.1
+++ importers/icalendar-importer.c	17 Nov 2003 04:07:21 -0000
@@ -137,11 +137,15 @@
 		if (child_kind != ICAL_VEVENT_COMPONENT
 		    && child_kind != ICAL_VTIMEZONE_COMPONENT) {
 
+			icalcompiter_next (&iter);
+
 			icalcomponent_remove_component (icalcomp, subcomp);
 			if (child_kind == ICAL_VTODO_COMPONENT)
 				vtodos = g_list_prepend (vtodos, subcomp);
 			else
 				icalcomponent_free (subcomp);
+
+			continue;
 		}
 
 		icalcompiter_next (&iter);
@@ -156,7 +160,7 @@
    freed afterwards. */
 static void
 prepare_tasks (icalcomponent *icalcomp, GList *vtodos)
-{
+
 	icalcomponent *subcomp;
 	GList *elem;
 	icalcompiter iter;
@@ -166,8 +170,12 @@
 		icalcomponent_kind child_kind = icalcomponent_isa (subcomp);
 		if (child_kind != ICAL_VTODO_COMPONENT
 		    && child_kind != ICAL_VTIMEZONE_COMPONENT) {
+			icalcompiter_next (&iter);
+			
 			icalcomponent_remove_component (icalcomp, subcomp);
 			icalcomponent_free (subcomp);
+
+			continue;
 		}
 
 		icalcompiter_next (&iter);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]