Re: [evolution-patches] [calendar-gw] fix for 314925
- From: "Chakravarthi P" <pchakravarthi novell com>
- To: <evolution-patches gnome org>
- Cc: P Chenthill <PChenthill novell com>
- Subject: Re: [evolution-patches] [calendar-gw] fix for 314925
- Date: Sat, 10 Sep 2005 00:41:58 -0600
On Fri, 2005-09-09 at 21:19 +0000, chenthill(P Chenthill) wrote:
> The memory need not be duped and it is also not freed causing a memory
> leak.
The memory needs to be duped as
1) the char * pointers returned by the icalparameter_get functions are
internal to the elements in struct attendee.
2) we free the struct attendee in set_attendee_list.
3) Again we free these pointers in e_cal_component_free_attendee_list ()
making it double free.
There fore, building a list of ECalComponentAttendee items *should not*
include pointers from the existing list of struct attendees(that is
attached to the priv->icalcomp )
Regarding freeing this new memory:
The memory *is* freed by calling e_cal_component_free_attendee_list ()
whenever a e_cal_component_set_attendee_list is called with a list of
ECalComponentAttendee items. Though it is not obvious that one should
call e_cal_component_free_attendee_list (), it is done currently at
every place e_cal_component_set_attendee_list () is called.
> The corruption is due to freeing of the priv->attendee list in the
> set_attendee list before a new attendee property is created which
needs
> to be fixed.
I do not understand how freeing of attendee property can cause
corruption as we are immediately creating new attendee property and
attaching to the icalcomp just below in set_attendee_list ().
IMHO, this freeing must remain as a new list of struct attendee is
created and set to the calendar component in set_attendee_list(). The
old list as well as the property *should be* freed.
In fact, I forgot to g_strdup for the value property which is included
in this patch.
Please review.
regards
>
> thanks, Chenthill.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.511
diff -u -p -w -r1.511 ChangeLog
--- ChangeLog 2 Sep 2005 18:43:18 -0000 1.511
+++ ChangeLog 10 Sep 2005 06:38:25 -0000
@@ -1,3 +1,14 @@
+2005-09-02 P. S. Chakravarthi <pchakravarthi novell com>
+
+ Fixes #314925
+ * libecal/e-cal-component.c:
+ (get_attendee_list): The function previously returned
+ some internal pointers of the calendar component for
+ making an attendee list which cause memory corruption
+ when used along with set_attendee_list() and/or
+ e_cal_component_free_attendee_list().
+ Code is modified to give copies of the fields.
+
2005-09-01 Chenthill Palanisamy <pchenthill novell com>
Fixes #114384
Index: libecal/e-cal-component.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal-component.c,v
retrieving revision 1.18
diff -u -p -w -r1.18 e-cal-component.c
--- libecal/e-cal-component.c 31 Aug 2005 04:21:54 -0000 1.18
+++ libecal/e-cal-component.c 10 Sep 2005 06:38:26 -0000
@@ -4395,10 +4395,10 @@ get_attendee_list (GSList *attendee_list
g_assert (attendee->prop != NULL);
a = g_new0 (ECalComponentAttendee, 1);
- a->value = icalproperty_get_attendee (attendee->prop);
+ a->value = g_strdup (icalproperty_get_attendee (attendee->prop));
if (attendee->member_param)
- a->member = icalparameter_get_member (attendee->member_param);
+ a->member = g_strdup (icalparameter_get_member (attendee->member_param));
if (attendee->cutype_param)
a->cutype = icalparameter_get_cutype (attendee->cutype_param);
else
@@ -4416,15 +4416,15 @@ get_attendee_list (GSList *attendee_list
else
a->rsvp = FALSE;
if (attendee->delfrom_param)
- a->delfrom = icalparameter_get_delegatedfrom (attendee->delfrom_param);
+ a->delfrom = g_strdup (icalparameter_get_delegatedfrom (attendee->delfrom_param));
if (attendee->delto_param)
- a->delto = icalparameter_get_delegatedto (attendee->delto_param);
+ a->delto = g_strdup (icalparameter_get_delegatedto (attendee->delto_param));
if (attendee->sentby_param)
- a->sentby = icalparameter_get_sentby (attendee->sentby_param);
+ a->sentby = g_strdup (icalparameter_get_sentby (attendee->sentby_param));
if (attendee->cn_param)
- a->cn = icalparameter_get_cn (attendee->cn_param);
+ a->cn = g_strdup (icalparameter_get_cn (attendee->cn_param));
if (attendee->language_param)
- a->language = icalparameter_get_language (attendee->language_param);
+ a->language = g_strdup (icalparameter_get_language (attendee->language_param));
*al = g_slist_prepend (*al, a);
}
[
Date Prev][
Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]