From c9e8aa94b0255f928bdd63539b333ff1f56f62f8 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 1 Feb 2015 23:06:28 +0000 Subject: Fix a potential memory leak when setting titles --- amiga/gui.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'amiga') diff --git a/amiga/gui.c b/amiga/gui.c index c3a7424eb..4ae03b797 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -4267,8 +4267,11 @@ static void gui_window_set_title(struct gui_window *g, const char *title) CLICKTAB_Labels, ~0, TAG_DONE); - SetClickTabNodeAttrs(node, TNA_Text, utf8title, - TNA_HintInfo, utf8title, + if(g->tabtitle) ami_utf8_free(g->tabtitle); + g->tabtitle = strdup(utf8title); + + SetClickTabNodeAttrs(node, TNA_Text, g->tabtitle, + TNA_HintInfo, g->tabtitle, TAG_DONE); RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS], @@ -4276,9 +4279,6 @@ static void gui_window_set_title(struct gui_window *g, const char *title) CLICKTAB_Labels, &g->shared->tab_list, TAG_DONE); - if(g->tabtitle) ami_utf8_free(g->tabtitle); - g->tabtitle = utf8title; - if(ClickTabBase->lib_Version < 53) RethinkLayout((struct Gadget *)g->shared->objects[GID_TABLAYOUT], g->shared->win, NULL, TRUE); @@ -4293,6 +4293,8 @@ static void gui_window_set_title(struct gui_window *g, const char *title) SetWindowTitles(g->shared->win, g->shared->wintitle, ami_gui_get_screen_title()); } } + + ami_utf8_free(utf8title); } static void ami_redraw_callback(void *p) -- cgit v1.2.3