[evolution-kolab] Bug #676165 - Calendar backend crashing when opening a memo several times for editing
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] Bug #676165 - Calendar backend crashing when opening a memo several times for editing
- Date: Mon, 21 May 2012 13:52:07 +0000 (UTC)
commit d880c377c97b5f72d2ffd4ecc981746bd4ca18dd
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Mon May 21 15:45:01 2012 +0200
Bug #676165 - Calendar backend crashing when opening a memo several times for editing
* libical memory was corrupted by calls to g_free()
on pointers returned by icalcomponent_as_ical_string(),
which returns pointers to memory owned by libical
(so it must not be free()d)
* fixed that in several locations inside libekolabconv
by g_strdup()ing the strings returned by the libical
function or using it as const pointer
.../main/src/evolution/priv-common-e-to-i.c | 3 ++-
.../main/src/evolution/priv-evolution-preserve.c | 3 ++-
src/libekolabconv/main/src/logging.c | 6 ++++--
src/libekolabconv/test/src/testbase.c | 3 ++-
4 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/libekolabconv/main/src/evolution/priv-common-e-to-i.c b/src/libekolabconv/main/src/evolution/priv-common-e-to-i.c
index d9e871f..e355902 100644
--- a/src/libekolabconv/main/src/evolution/priv-common-e-to-i.c
+++ b/src/libekolabconv/main/src/evolution/priv-common-e-to-i.c
@@ -66,7 +66,8 @@ get_vtimezone (const ECalComponentWithTZ *ectz)
icalcomponent_remove_property (cloned_icc, dtstamp);
free(dtstamp);
- ical_str = icalcomponent_as_ical_string (cloned_icc);
+ /* memory returned by *_as_ical_string() is owned by libical */
+ ical_str = g_strdup (icalcomponent_as_ical_string (cloned_icc));
icalcomponent_free (cloned_icc);
return ical_str;
diff --git a/src/libekolabconv/main/src/evolution/priv-evolution-preserve.c b/src/libekolabconv/main/src/evolution/priv-evolution-preserve.c
index 3360b50..d3da907 100644
--- a/src/libekolabconv/main/src/evolution/priv-evolution-preserve.c
+++ b/src/libekolabconv/main/src/evolution/priv-evolution-preserve.c
@@ -39,7 +39,8 @@ i_evo_store_add_prop(I_common *i_common, icalproperty *prop, icalcomponent_kind
comp = icalcomponent_new(kind);
prop = icalproperty_new_clone(prop);
icalcomponent_add_property(comp, prop);
- i_common->evolution_store = icalcomponent_as_ical_string(comp);
+ /* memory returned by *_as_ical_string() is owned by libical */
+ i_common->evolution_store = g_strdup (icalcomponent_as_ical_string(comp));
icalcomponent_free(comp);
}
diff --git a/src/libekolabconv/main/src/logging.c b/src/libekolabconv/main/src/logging.c
index ebd24b0..e1198d0 100644
--- a/src/libekolabconv/main/src/logging.c
+++ b/src/libekolabconv/main/src/logging.c
@@ -54,15 +54,17 @@ log_evolution_ical (const gchar *message, const ECalComponentWithTZ* epim)
icalcomponent *ical_vevent = e_cal_component_get_icalcomponent ((ECalComponent*) epim->maincomp);
icalcomponent *ical_vcal = icalcomponent_new_vcalendar ();
icalcomponent *ical_vtz = NULL;
+ const gchar *ical_str = NULL;
+
if (epim->timezone != NULL) {
ical_vtz = e_cal_component_get_icalcomponent ((ECalComponent*) epim->timezone);
icalcomponent_add_component (ical_vcal, ical_vtz);
}
icalcomponent_add_component (ical_vcal, ical_vevent);
- gchar *ical_str = icalcomponent_as_ical_string (ical_vcal);
+ /* memory returned by *_as_ical_string() is owned by libical */
+ ical_str = icalcomponent_as_ical_string (ical_vcal);
log_debug("%s\n%s", message, ical_str);
- g_free(ical_str);
if (ical_vtz != NULL)
icalcomponent_remove_component (ical_vcal, ical_vtz);
diff --git a/src/libekolabconv/test/src/testbase.c b/src/libekolabconv/test/src/testbase.c
index 82f6017..0ad23a2 100644
--- a/src/libekolabconv/test/src/testbase.c
+++ b/src/libekolabconv/test/src/testbase.c
@@ -134,7 +134,8 @@ create_evolution_vcard_tested (const ECalComponentWithTZ* epim, gint *stage)
icalcomponent_add_component (ical_vcal, ical_vtz);
}
icalcomponent_add_component (ical_vcal, ical_vevent);
- ical_str = icalcomponent_as_ical_string (ical_vcal);
+ /* memory returned by *_as_ical_string() is owned by libical */
+ ical_str = g_strdup (icalcomponent_as_ical_string (ical_vcal));
/* free allocated resources */
if (ical_vtz != NULL)
icalcomponent_remove_component(ical_vcal, ical_vtz);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]