Fix static analysis issue 27/281627/3
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 20 Sep 2022 05:29:16 +0000 (14:29 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 20 Sep 2022 06:59:06 +0000 (15:59 +0900)
Change-Id: I93c65806e99bcd1744c6c1cd6ea8b05044522af4
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
parser/src/pkgmgr_parser_deprecated.c

index 0dd7367..9566245 100644 (file)
@@ -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;
                }