updated description
authorArt Cancro <ajc@citadel.org>
Sun, 14 Jan 2024 03:04:16 +0000 (22:04 -0500)
committerArt Cancro <ajc@citadel.org>
Sun, 14 Jan 2024 03:04:16 +0000 (22:04 -0500)
citadel/server/modules/calendar/serv_calendar.c

index 4d86058276178341e488c71a2346c4b0324d48c2..b8eaaa6ca06996c14b575be0e88a303dc019a02c 100644 (file)
@@ -1490,26 +1490,23 @@ void ical_getics_backend(long msgnum, void *data) {
 
        if (ird.cal == NULL) return;
 
-       // Here we go: put the VEVENT into the VCALENDAR.  We now no longer
-       // are responsible for "the_request"'s memory -- it will be freed
-       // when we free "encaps".
+       // Here we go: put the VEVENT componment into the VCALENDAR container.
 
-       // If the top-level component is *not* a VCALENDAR, we can drop it right in.
-       // This will almost never happen.
+       // If the top-level component is *not* a VCALENDAR container, we can drop it right in.
+       // This is rare but we have to be able to handle it.
        if (icalcomponent_isa(ird.cal) != ICAL_VCALENDAR_COMPONENT) {
                icalcomponent_add_component(encaps, ird.cal);
+               // And now, the parent VCALENDAR container owns the child component's memory.
        }
 
-       // In the more likely event that we're looking at a VCALENDAR with the VEVENT
-       // and other components encapsulated inside, we have to extract them.
+       // In the more likely event that we're looking at a VCALENDAR container with the VEVENT
+       // and other components encapsulated inside, we have to extract them first.
        else {
                for     (c = icalcomponent_get_first_component(ird.cal, ICAL_ANY_COMPONENT);
                        (c != NULL);
                        c = icalcomponent_get_next_component(ird.cal, ICAL_ANY_COMPONENT)
                ) {
-
                        // For VTIMEZONE components, suppress duplicates of the same tzid
-
                        if (icalcomponent_isa(c) == ICAL_VTIMEZONE_COMPONENT) {
                                icalproperty *p = icalcomponent_get_first_property(c, ICAL_TZID_PROPERTY);
                                if (p) {
@@ -1525,7 +1522,7 @@ void ical_getics_backend(long msgnum, void *data) {
                                icalcomponent_add_component(encaps, icalcomponent_new_clone(c));
                        }
                }
-               icalcomponent_free(ird.cal);
+               icalcomponent_free(ird.cal);            // we cloned this component so free the original.
        }
 }