Index: calendar/ChangeLog
===================================================================
--- calendar/ChangeLog	(revision 8106)
+++ calendar/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2007-10-05  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #420167
+
+	* backends/contacts/e-cal-backend-contacts.c: (contact_record_new),
+	(contact_record_free), (contact_record_cb_new):
+	Ref and Unref backend used in ContactRecord to be sure it isn't
+	freed before we endup with it.
+
 2007-10-03  Matthew Barnes  <mbarnes@redhat.com>
 
 	** Fixes part of bug #469657
Index: calendar/backends/contacts/e-cal-backend-contacts.c
===================================================================
--- calendar/backends/contacts/e-cal-backend-contacts.c	(revision 8106)
+++ calendar/backends/contacts/e-cal-backend-contacts.c	(working copy)
@@ -141,7 +141,7 @@
         ContactRecord *cr = g_new0 (ContactRecord, 1);
 	char *comp_str;
         
-        cr->cbc = cbc;
+        cr->cbc = g_object_ref (cbc);
         cr->contact = contact;
         cr->comp_birthday = create_birthday (cbc, contact);
         cr->comp_anniversary = create_anniversary (cbc, contact);
@@ -196,7 +196,8 @@
 		g_free (comp_str);
 		g_object_unref (G_OBJECT (cr->comp_anniversary));
 	}
-        
+
+	g_object_unref (cr->cbc);
         g_free (cr);
 }
 
@@ -212,7 +213,7 @@
 {
         ContactRecordCB *cb_data = g_new (ContactRecordCB, 1);
 
-        cb_data->cbc = cbc;
+        cb_data->cbc = g_object_ref (cbc);
         cb_data->sexp = sexp;
         cb_data->result = NULL;
 
