summaryrefslogtreecommitdiff
path: root/src/libical/icalderivedvalue.c.in
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2019-10-14 21:23:20 +0200
committerCorentin Noël <corentin@elementary.io>2019-10-15 18:45:40 +0200
commit57e4b56fac028f83b7a467001ea982b47ab44580 (patch)
tree02092298900dbc9a0d44c6a2f1476191df5ba1ca /src/libical/icalderivedvalue.c.in
parentf3239364efcd91ba29c79e4122820805660138b3 (diff)
downloadlibical-git-57e4b56fac028f83b7a467001ea982b47ab44580.tar.gz
Let icalattach_new_from_data() use the 'free_fn' argument againmcrha/annotations
This had been disabled with commit 7a2f318bacae5521848963d96a3a644bc6be1d01 (in time of 1.0.1) to fix inline attachments crashing. That commit could eventually cause memory leaks and higher memory usage. This change adds necessary strdup() calls on places where required only and makes use of the 'free_fn' argument again. It also fixes libical-glib's i_cal_attach_new_from_bytes(), which relies on this 'free_fn'.
Diffstat (limited to 'src/libical/icalderivedvalue.c.in')
-rw-r--r--src/libical/icalderivedvalue.c.in8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libical/icalderivedvalue.c.in b/src/libical/icalderivedvalue.c.in
index 140b267e..fad163c1 100644
--- a/src/libical/icalderivedvalue.c.in
+++ b/src/libical/icalderivedvalue.c.in
@@ -499,6 +499,12 @@ icalvalue *icalvalue_new_binary(const char * v)
return (icalvalue*)impl;
}
+static void free_icalvalue_attach_data(char *data, void *user_data)
+{
+ _unused(user_data);
+ free(data);
+}
+
void icalvalue_set_binary(icalvalue *value, const char * v)
{
struct icalvalue_impl *impl;
@@ -512,7 +518,7 @@ void icalvalue_set_binary(icalvalue *value, const char * v)
if (impl->data.v_attach)
icalattach_unref(impl->data.v_attach);
- impl->data.v_attach = icalattach_new_from_data(v, NULL, 0);
+ impl->data.v_attach = icalattach_new_from_data(strdup(v), free_icalvalue_attach_data, 0);
}
const char *icalvalue_get_binary(const icalvalue *value)