Fix a potential memory leak when setting titles

This commit is contained in:
Chris Young 2015-02-01 23:06:28 +00:00
parent 7b0969680b
commit c9e8aa94b0

View File

@ -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)