Fix static analyzer issues 91/163891/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 14 Dec 2017 02:27:18 +0000 (11:27 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Thu, 14 Dec 2017 02:27:48 +0000 (11:27 +0900)
Fix to check return value.

Change-Id: Ib30045abd4bae40ff7585312b4402771ce2ee317
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
parser/src/pkgmgr_parser_deprecated.c

index a880da3..bae8fdc 100644 (file)
@@ -75,8 +75,13 @@ static void __save_xml_attribute(xmlTextReaderPtr reader, char *attribute, char
 
 static void __save_xml_value(xmlTextReaderPtr reader, char **xml_attribute)
 {
-       xmlTextReaderRead(reader);
-       const xmlChar *attrib_val = xmlTextReaderConstValue(reader);
+       int ret;
+       const xmlChar *attrib_val;
+
+       ret = xmlTextReaderRead(reader);
+       if (ret == -1)
+               return;
+       attrib_val = xmlTextReaderConstValue(reader);
 
        if (attrib_val)
                *xml_attribute = strdup((const char *)attrib_val);
@@ -323,13 +328,18 @@ static char *__get_icon_with_path(const char *icon, uid_t uid)
 
 static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid)
 {
+       int ret;
+       char *text;
+
        __save_xml_attribute(reader, "section", &icon->section, NULL);
        __save_xml_attribute(reader, "size", &icon->size, NULL);
        __save_xml_attribute(reader, "resolution", &icon->resolution, NULL);
        __save_xml_lang(reader, &icon->lang);
 
-       xmlTextReaderRead(reader);
-       char *text  = ASCII(xmlTextReaderValue(reader));
+       ret = xmlTextReaderRead(reader);
+       if (ret == -1)
+               return 0;
+       text  = ASCII(xmlTextReaderValue(reader));
        if (text) {
                icon->text = __get_icon_with_path(text, uid);
                free(text);