]> code.citadel.org Git - citadel.git/commitdiff
* don't loose pointers to cal structs and destruct them properly.
authorWilfried Göesgens <willi@citadel.org>
Sun, 21 Jan 2007 12:13:28 +0000 (12:13 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 21 Jan 2007 12:13:28 +0000 (12:13 +0000)
citadel/serv_calendar.c

index b7871e8e52bbc2a8fb66c3d8cf7999c26ccf837c..789e3c7614023ee7cfd9840270bd46f0fea3df8e 100644 (file)
@@ -1847,7 +1847,7 @@ void ical_ctdl_set_exclusive_msgid(char *name, char *filename, char *partnum,
                char *disp, void *content, char *cbtype, char *cbcharset, size_t length,
                char *encoding, void *cbuserdata)
 {
-       icalcomponent *cal, *nested_event, *nested_todo;
+       icalcomponent *cal, *nested_event, *nested_todo, *whole_cal;
        icalproperty *p;
        struct icalmessagemod *imm;
        char new_uid[SIZ];
@@ -1860,44 +1860,47 @@ void ical_ctdl_set_exclusive_msgid(char *name, char *filename, char *partnum,
         * to that string.
         */
        if (!strcasecmp(cbtype, "text/calendar")) {
-               cal = icalcomponent_new_from_string(content);
+               whole_cal = icalcomponent_new_from_string(content);
+               cal = whole_cal;
                if (cal != NULL) {
                        if (icalcomponent_isa(cal) == ICAL_VCALENDAR_COMPONENT) {
                                nested_event = icalcomponent_get_first_component(
-                                       cal, ICAL_VEVENT_COMPONENT
-                               );
-                               nested_todo = icalcomponent_get_first_component(
-                                       cal, ICAL_VTODO_COMPONENT
-                               );
+                                       cal, ICAL_VEVENT_COMPONENT);
                                if (nested_event != NULL) {
                                        cal = nested_event;
                                }
-                               else if (nested_todo != NULL) {
-                                       cal = nested_todo;
+                               else {
+                                       nested_todo = icalcomponent_get_first_component(
+                                               cal, ICAL_VTODO_COMPONENT);
+                                       if (nested_todo != NULL) 
+                                               cal = nested_todo;
                                }
                        }
-               }
-               if (cal != NULL) {
-                       p = ical_ctdl_get_subprop(cal, ICAL_UID_PROPERTY);
-                       if (p == NULL) {
-                               /* If there's no uid we must generate one */
-                               generate_uuid(new_uid);
-                               icalcomponent_add_property(cal, icalproperty_new_uid(new_uid));
+                       
+                       if (cal != NULL) {
                                p = ical_ctdl_get_subprop(cal, ICAL_UID_PROPERTY);
-                       }
-                       if (p != NULL) {
-                               strcpy(imm->uid, icalproperty_get_comment(p));
-                               /* strcpy(imm->subject, icalproperty_get_comment(p)); old aethera hack */
-                       }
-                       p = ical_ctdl_get_subprop(cal, ICAL_SUMMARY_PROPERTY);
-                       if (p != NULL) {
-                               strcpy(imm->subject, icalproperty_get_comment(p));
-                       }
-                       p = ical_ctdl_get_subprop(cal, ICAL_DTSTART_PROPERTY);
-                       if (p != NULL) {
-                               imm->dtstart = icaltime_as_timet(icalproperty_get_dtstart(p));
+                               if (p == NULL) {
+                                       /* If there's no uid we must generate one */
+                                       generate_uuid(new_uid);
+                                       icalcomponent_add_property(cal, icalproperty_new_uid(new_uid));
+                                       p = ical_ctdl_get_subprop(cal, ICAL_UID_PROPERTY);
+                               }
+                               if (p != NULL) {
+                                       strcpy(imm->uid, icalproperty_get_comment(p));
+                                       /* strcpy(imm->subject, icalproperty_get_comment(p)); old aethera hack */
+                               }
+                               p = ical_ctdl_get_subprop(cal, ICAL_SUMMARY_PROPERTY);
+                               if (p != NULL) {
+                                       strcpy(imm->subject, icalproperty_get_comment(p));
+                               }
+                               p = ical_ctdl_get_subprop(cal, ICAL_DTSTART_PROPERTY);
+                               if (p != NULL) {
+                                       imm->dtstart = icaltime_as_timet(icalproperty_get_dtstart(p));
+                               }
                        }
                        icalcomponent_free(cal);
+                       if (whole_cal != cal)
+                           icalcomponent_free(whole_cal);
                }
        }
 }
@@ -1905,7 +1908,6 @@ void ical_ctdl_set_exclusive_msgid(char *name, char *filename, char *partnum,
 
 
 
-
 /*
  * See if we need to prevent the object from being saved (we don't allow
  * MIME types other than text/calendar in "calendar" or "tasks"  rooms).  Also,