From: Daeheyon Jung Date: Tue, 12 Dec 2017 07:53:22 +0000 (+0900) Subject: Fix static analysis issues X-Git-Tag: accepted/tizen/4.0/unified/20180111.044152^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_4.0;p=platform%2Fcore%2Fappfw%2Fxdgmime.git Fix static analysis issues Change-Id: I923c1cea45956fad4f985d843b91e0f1b5f81de1 Signed-off-by: Daeheyon Jung --- diff --git a/xdgmime/src/xdgmime.c b/xdgmime/src/xdgmime.c index 7f1dc9c..9e0e5e7 100644 --- a/xdgmime/src/xdgmime.c +++ b/xdgmime/src/xdgmime.c @@ -168,6 +168,11 @@ xdg_mime_init_from_directory (const char *directory) return FALSE; } + else + { + free(cache); + return TRUE; + } } } free (file_name); diff --git a/xdgmime/src/xdgmimeglobs2.c b/xdgmime/src/xdgmimeglobs2.c index e5ad349..00870e2 100644 --- a/xdgmime/src/xdgmimeglobs2.c +++ b/xdgmime/src/xdgmimeglobs2.c @@ -176,7 +176,7 @@ mime_type_info_list_add_file_name(mime_type_info_list *mtil, const char *mime_type, const char *file_name) { - if(!mtil) return; + if(!mtil || !mime_type || !file_name) return; mime_type_info **mti; int found = 0; @@ -248,6 +248,8 @@ mime_type_info_list_reload(mime_type_info_list *mtil) /* read globs2, and construct data structure */ globs2 = fopen(GLOBS2_PATH, "r"); + if (!globs2) return; + char *weight, *mime_type, *file_name, *saveptr = NULL; while(fgets(buf, 255, globs2)) { /* skip comment */ diff --git a/xdgmime/src/xdgmimemagic.c b/xdgmime/src/xdgmimemagic.c index fbc03af..7bd727c 100644 --- a/xdgmime/src/xdgmimemagic.c +++ b/xdgmime/src/xdgmimemagic.c @@ -240,7 +240,7 @@ _xdg_mime_magic_read_a_number (FILE *magic_file, errno = 0; retval = strtol (number_string, NULL, 10); - if ((retval < INT_MIN) || (retval > INT_MAX) || (errno != 0)) + if ((retval == LONG_MIN) || (retval == LONG_MAX) || (errno != 0)) return -1; } @@ -280,8 +280,12 @@ _xdg_mime_magic_parse_header (FILE *magic_file, XdgMimeMagicMatch *match) return XDG_MIME_MAGIC_ERROR; buffer = (char *)_xdg_mime_magic_read_to_newline (magic_file, &end_of_file); - if (end_of_file) + if (end_of_file) { + if (buffer) + free(buffer); + return XDG_MIME_MAGIC_EOF; + } end_ptr = buffer; while (*end_ptr != ']' && *end_ptr != '\000' && *end_ptr != '\n') @@ -791,7 +795,6 @@ _xdg_mime_magic_read_magic_file (XdgMimeMagic *mime_magic, case XDG_MIME_MAGIC_ERROR: state = _xdg_mime_magic_parse_error (magic_file); break; - case XDG_MIME_MAGIC_EOF: default: /* Make the compiler happy */ assert (0);