change the order of setting root element about xmlDoc 64/307664/1
authordyamy-lee <dyamy.lee@samsung.com>
Mon, 11 Mar 2024 07:27:48 +0000 (16:27 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Tue, 12 Mar 2024 06:41:21 +0000 (15:41 +0900)
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

index 44d0f8e..9ccc88d 100644 (file)
@@ -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) {