From 046c54a1181948742ad8848ed2ad0a04209eeae9 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 28 Apr 2008 17:47:45 +0200 Subject: [PATCH] [taglist] Fix memory leak in parsing and escape title Signed-off-by: Julien Danjou --- widgets/taglist.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/widgets/taglist.c b/widgets/taglist.c index fd52a990b..8ab13defd 100644 --- a/widgets/taglist.c +++ b/widgets/taglist.c @@ -40,15 +40,25 @@ static char * tag_markup_parse(tag_t *t, const char *str, ssize_t len) { const char *elements[] = { "title", NULL }; - const char *elements_sub[] = { t->name , NULL }; + char *title_esc = g_markup_escape_text(t->name, -1); + const char *elements_sub[] = { title_esc , NULL }; markup_parser_data_t *p; + char *ret; p = markup_parser_data_new(elements, elements_sub, countof(elements)); - if(!markup_parse(p, str, len)) - return a_strdup(str); + if(markup_parse(p, str, len)) + { + ret = p->text; + p->text = NULL; + } + else + ret = a_strdup(str); - return p->text; + markup_parser_data_delete(&p); + p_delete(&title_esc); + + return ret; } /** Check if at least one client is tagged with tag number t and is on screen