From 5638661157049d53bb6aec1f0bff12ef97aec6bf Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 30 Apr 2008 15:46:19 +0200 Subject: [PATCH] [markup] Fix memory leak Signed-off-by: Julien Danjou --- common/markup.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/common/markup.c b/common/markup.c index 71f584c8a..620e5740f 100644 --- a/common/markup.c +++ b/common/markup.c @@ -64,12 +64,14 @@ markup_parse_start_element(GMarkupParseContext *context __attribute__ ((unused)) p->attribute_names[i][j] = a_strdup(attribute_names[j]); p->attribute_values[i][j] = a_strdup(attribute_values[j]); } + if(p->elements_sub && p->elements_sub[i]) { asprintf(&newtext, "%s%s", NONULL(p->text), p->elements_sub[i]); p_delete(&p->text); p->text = newtext; } + return; } @@ -189,15 +191,18 @@ markup_parser_data_delete(markup_parser_data_t **p) for(i = 0; (*p)->elements[i]; i++) if((*p)->attribute_names[i]) { - for(j = 0; (*p)->attribute_names[i][j]; j++); + for(j = 0; (*p)->attribute_names[i][j]; j++) { - p_delete(&(*p)->attribute_names[i][j]); - p_delete(&(*p)->attribute_values[i][j]); + p_delete(&((*p)->attribute_names[i][j])); + p_delete(&((*p)->attribute_values[i][j])); } - p_delete(&(*p)->attribute_names[i]); - p_delete(&(*p)->attribute_values[i]); + p_delete(&((*p)->attribute_names[i])); + p_delete(&((*p)->attribute_values[i])); } + p_delete(&(*p)->attribute_names); + p_delete(&(*p)->attribute_values); + p_delete(&(*p)->text); p_delete(p); } @@ -236,6 +241,7 @@ markup_parse(markup_parser_data_t *data, const char *str, ssize_t slen) { warn("unable to parse text \"%s\": %s\n", str, error->message); g_error_free(error); + g_markup_parse_context_free(mkp_ctx); return false; }