From 4c793dad4b8ee41aad2472004c50e4dbbb88e559 Mon Sep 17 00:00:00 2001 From: dyamy-lee Date: Mon, 11 Mar 2024 16:27:48 +0900 Subject: [PATCH] change the order of setting root element about xmlDoc When calling 'xmlDocSetRootElement', it removes 'root' in this inside logic. So, the 'root' which allocated from 'xmlNewNode' has possiblity of free in it. Therefore, this patch changed the order of calling this function after calling 'xmlDocSetRootElement'. Change-Id: I64c3dc5154bef464586c4a81df99961965259cbf --- engine-parser/src/vc-engine-parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine-parser/src/vc-engine-parser.c b/engine-parser/src/vc-engine-parser.c index 44d0f8e..9ccc88d 100644 --- a/engine-parser/src/vc-engine-parser.c +++ b/engine-parser/src/vc-engine-parser.c @@ -353,6 +353,8 @@ static int __write_metadata_inxml(const char *pkgid, const char *appid, GList *l xmlNodePtr root = NULL; xmlNodePtr cur = NULL; + xmlDocSetRootElement(g_doc, root); + root = xmlNewNode(NULL, (const xmlChar*)VC_TAG_ENGINE_BASE); if (NULL == root) { @@ -360,7 +362,6 @@ static int __write_metadata_inxml(const char *pkgid, const char *appid, GList *l // xmlFreeDoc(g_doc); return -1; } - xmlDocSetRootElement(g_doc, root); iter = g_list_first(list); while (NULL != iter) { -- 2.7.4