From d1d82ff32342293d167d61ff60a6831ecdb2f95c Mon Sep 17 00:00:00 2001 From: Radek Krejci Date: Fri, 5 Feb 2016 13:14:05 +0100 Subject: [PATCH] data tree BUGFIX memory leak Fixes #16 --- src/tree_data.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tree_data.c b/src/tree_data.c index 646338cdf7..9eca23640f 100644 --- a/src/tree_data.c +++ b/src/tree_data.c @@ -49,7 +49,7 @@ static struct lyd_node * lyd_parse_(struct ly_ctx *ctx, const struct lys_node *parent, const char *data, LYD_FORMAT format, int options) { - struct lyxml_elem *xml; + struct lyxml_elem *xml, *xmlnext; struct lyd_node *result = NULL; int xmlopt = LYXML_PARSE_MULTIROOT; @@ -67,7 +67,9 @@ lyd_parse_(struct ly_ctx *ctx, const struct lys_node *parent, const char *data, case LYD_XML_FORMAT: xml = lyxml_parse_mem(ctx, data, xmlopt); result = lyd_parse_xml(ctx, &xml, options, parent); - lyxml_free(ctx, xml); + LY_TREE_FOR_SAFE(xml, xmlnext, xml) { + lyxml_free(ctx, xml); + } break; case LYD_JSON: result = lyd_parse_json(ctx, parent, data, options);