Index: calendar/ChangeLog
===================================================================
--- calendar/ChangeLog	(revision 10191)
+++ calendar/ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2009-03-24  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #573187
+
+	* backends/caldav/e-cal-backend-caldav.c: (caldav_server_list_objects),
+	(check_calendar_changed_on_server), (synchronize_cache), (pack_cobj):
+	More leak fixes.
+
 2009-03-23  Milan Crha  <mcrha@redhat.com>
 
 	** Fix for bug #573187
Index: calendar/backends/caldav/e-cal-backend-caldav.c
===================================================================
--- calendar/backends/caldav/e-cal-backend-caldav.c	(revision 10191)
+++ calendar/backends/caldav/e-cal-backend-caldav.c	(working copy)
@@ -1002,7 +1002,8 @@ check_calendar_changed_on_server (ECalBa
 		return FALSE;
 
 	doc = xmlNewDoc ((xmlChar *) "1.0");
-	root = xmlNewNode (NULL, (xmlChar *) "propfind");
+	root = xmlNewDocNode (doc, NULL, (xmlChar *) "propfind", NULL);
+	xmlDocSetRootElement (doc, root);
 	nsdav = xmlNewNs (root, (xmlChar *) "DAV:", NULL);
 	ns = xmlNewNs (root, (xmlChar *) "http://calendarserver.org/ns/", (xmlChar *) "CS");
 
@@ -1081,10 +1082,10 @@ caldav_server_list_objects (ECalBackendC
 	/* Maybe we should just do a g_strdup_printf here? */
 	/* Prepare request body */
 	doc = xmlNewDoc ((xmlChar *) "1.0");
-	root = xmlNewNode (NULL, (xmlChar *) "calendar-query");
-	nscd = xmlNewNs (root, (xmlChar *) "urn:ietf:params:xml:ns:caldav",
-			 (xmlChar *) "C");
+	root = xmlNewDocNode (doc, NULL, (xmlChar *) "calendar-query", NULL);
+	nscd = xmlNewNs (root, (xmlChar *) "urn:ietf:params:xml:ns:caldav", (xmlChar *) "C");
 	xmlSetNs (root, nscd);
+	xmlDocSetRootElement (doc, root);
 
 	/* Add webdav tags */
 	nsdav = xmlNewNs (root, (xmlChar *) "DAV:", (xmlChar *) "D");
@@ -1494,7 +1495,8 @@ synchronize_cache (ECalBackendCalDAV *cb
 
 		if (res) {
 			cobjs = g_list_remove (cobjs, ccomp);
-			g_object_unref (ccomp);
+			if (ccomp)
+				g_object_unref (ccomp);
 		}
 
 		caldav_object_free (object, FALSE);
@@ -1938,6 +1940,7 @@ pack_cobj (ECalBackendCalDAV *cbdav, ECa
 	}
 
 	objstr = icalcomponent_as_ical_string_r (calcomp);
+	icalcomponent_free (calcomp);
 
 	g_assert (objstr);
 
