summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaeheyon Jung <darrenh.jung@samsung.com>2017-12-12 16:53:22 +0900
committerDaeheyon Jung <darrenh.jung@samsung.com>2017-12-18 17:01:43 +0900
commit72c1b75d405995bd07d8f858b2ddb4dc1004663a (patch)
tree30443a2786f1d7ee1fcd1713bd271752279a45ee
parent5aa04c67c5f785599959b912b809f8db3425d63c (diff)
downloadxdgmime-tizen_5.5_tv.tar.gz
xdgmime-tizen_5.5_tv.tar.bz2
xdgmime-tizen_5.5_tv.zip
Change-Id: I923c1cea45956fad4f985d843b91e0f1b5f81de1 Signed-off-by: Daeheyon Jung <darrenh.jung@samsung.com>
-rw-r--r--xdgmime/src/xdgmime.c5
-rw-r--r--xdgmime/src/xdgmimeglobs2.c4
-rw-r--r--xdgmime/src/xdgmimemagic.c9
3 files changed, 14 insertions, 4 deletions
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);