From 10e1b6ac07f7216d18ce11f785faf351986efc20 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 20 Sep 2022 14:29:16 +0900 Subject: [PATCH] Fix static analysis issue Change-Id: I93c65806e99bcd1744c6c1cd6ea8b05044522af4 Signed-off-by: Sangyoon Jang --- parser/src/pkgmgr_parser_deprecated.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/parser/src/pkgmgr_parser_deprecated.c b/parser/src/pkgmgr_parser_deprecated.c index 0dd7367..9566245 100644 --- a/parser/src/pkgmgr_parser_deprecated.c +++ b/parser/src/pkgmgr_parser_deprecated.c @@ -339,7 +339,7 @@ static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid) text = ASCII(xmlTextReaderValue(reader)); if (text) { icon->text = __get_icon_with_path(text, uid); - free(text); + xmlFree(text); } return 0; @@ -1229,14 +1229,20 @@ static int __run_tag_parser_prestep(void *lib_handle, xmlTextReaderPtr reader, A if (copyDocPtr == NULL) return -1; xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr); - if (rootElement == NULL) + if (rootElement == NULL) { + xmlFreeDoc(copyDocPtr); return -1; + } xmlNode *cur_node = xmlFirstElementChild(rootElement); - if (cur_node == NULL) + if (cur_node == NULL) { + xmlFreeDoc(copyDocPtr); return -1; + } xmlNode *temp = xmlTextReaderExpand(reader); - if (temp == NULL) + if (temp == NULL) { + xmlFreeDoc(copyDocPtr); return -1; + } xmlNode *next_node = NULL; while (cur_node != NULL) { if ((strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) && @@ -1249,8 +1255,10 @@ static int __run_tag_parser_prestep(void *lib_handle, xmlTextReaderPtr reader, A cur_node = next_node; } } - if (cur_node == NULL) + if (cur_node == NULL) { + xmlFreeDoc(copyDocPtr); return -1; + } next_node = xmlNextElementSibling(cur_node); if (next_node) { cur_node->next = NULL; @@ -1285,8 +1293,8 @@ static void __process_tag(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE if (strcmp(tag, ASCII(elementName)) == 0) { _LOGD("find : tag[%s] ACTION_TYPE[%d] pkg[%s]\n", tag, action, pkgid); __run_tag_parser_prestep(lib_handle, reader, action, pkgid); - break; } + xmlFree(elementName); break; } -- 2.7.4