From 6b30fb8d63de2ee42e18db3b32e8639b4b9ee181 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 14 Dec 2017 11:27:18 +0900 Subject: [PATCH] Fix static analyzer issues Fix to check return value. Change-Id: Ib30045abd4bae40ff7585312b4402771ce2ee317 Signed-off-by: Sangyoon Jang --- parser/src/pkgmgr_parser_deprecated.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/parser/src/pkgmgr_parser_deprecated.c b/parser/src/pkgmgr_parser_deprecated.c index a880da3..bae8fdc 100644 --- a/parser/src/pkgmgr_parser_deprecated.c +++ b/parser/src/pkgmgr_parser_deprecated.c @@ -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); -- 2.7.4