From 94e2b5edb140ee774955ae517433d9f795366ee5 Mon Sep 17 00:00:00 2001 From: o9000 Date: Sat, 4 Mar 2017 12:20:44 +0100 Subject: [PATCH] Fix double free in separator --- src/separator/separator.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/separator/separator.c b/src/separator/separator.c index 8e36756..26693f3 100644 --- a/src/separator/separator.c +++ b/src/separator/separator.c @@ -38,6 +38,14 @@ void destroy_separator(void *obj) free_and_null(separator); } +gpointer copy_separator(gconstpointer arg, gpointer data) +{ + Separator *old = (Separator *)arg; + Separator *copy = (Separator *)calloc(1, sizeof(Separator)); + memcpy(copy, old, sizeof(Separator)); + return copy; +} + void init_separator() { GList *to_remove = panel_config.separator_list; @@ -72,7 +80,7 @@ void init_separator_panel(void *p) // panel->separator_list is now a copy of the pointer panel_config.separator_list // We make it a deep copy - panel->separator_list = g_list_copy_deep(panel_config.separator_list, NULL, NULL); + panel->separator_list = g_list_copy_deep(panel_config.separator_list, copy_separator, NULL); for (GList *l = panel->separator_list; l; l = l->next) { Separator *separator = (Separator *)l->data;