Fix static analysis issues 04/164104/2 accepted/tizen_4.0_unified accepted/tizen_5.0_unified accepted/tizen_5.5_unified accepted/tizen_5.5_unified_mobile_hotfix accepted/tizen_5.5_unified_wearable_hotfix tizen_4.0 tizen_4.0_tv tizen_5.0 tizen_5.5 tizen_5.5_mobile_hotfix tizen_5.5_tv tizen_5.5_wearable_hotfix accepted/tizen/4.0/unified/20180111.044152 accepted/tizen/5.0/unified/20181102.020238 accepted/tizen/5.5/unified/20191031.025534 accepted/tizen/5.5/unified/mobile/hotfix/20201027.085129 accepted/tizen/5.5/unified/wearable/hotfix/20201027.114720 accepted/tizen/unified/20180105.065502 submit/tizen/20180104.013833 submit/tizen_4.0/20180104.013937 submit/tizen_5.0/20181101.000003 submit/tizen_5.5/20191031.000003 submit/tizen_5.5_mobile_hotfix/20201026.185103 submit/tizen_5.5_wearable_hotfix/20201026.184303 tizen_4.0.IoT.p2_release tizen_5.5.m2_release
authorDaeheyon Jung <darrenh.jung@samsung.com>
Tue, 12 Dec 2017 07:53:22 +0000 (16:53 +0900)
committerDaeheyon Jung <darrenh.jung@samsung.com>
Mon, 18 Dec 2017 08:01:43 +0000 (17:01 +0900)
Change-Id: I923c1cea45956fad4f985d843b91e0f1b5f81de1
Signed-off-by: Daeheyon Jung <darrenh.jung@samsung.com>
xdgmime/src/xdgmime.c
xdgmime/src/xdgmimeglobs2.c
xdgmime/src/xdgmimemagic.c

index 7f1dc9c..9e0e5e7 100644 (file)
@@ -168,6 +168,11 @@ xdg_mime_init_from_directory (const char *directory)
 
               return FALSE;
             }
+          else
+            {
+              free(cache);
+              return TRUE;
+            }
         }
     }
   free (file_name);
index e5ad349..00870e2 100644 (file)
@@ -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 */
index fbc03af..7bd727c 100644 (file)
@@ -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);