diff options
author | Milan Crha <mcrha@redhat.com> | 2019-10-14 21:23:20 +0200 |
---|---|---|
committer | Corentin Noël <corentin@elementary.io> | 2019-10-15 18:45:40 +0200 |
commit | 57e4b56fac028f83b7a467001ea982b47ab44580 (patch) | |
tree | 02092298900dbc9a0d44c6a2f1476191df5ba1ca /src/libical/icalderivedvalue.c.in | |
parent | f3239364efcd91ba29c79e4122820805660138b3 (diff) | |
download | libical-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.in | 8 |
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) |