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;
/* 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 */
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;
}
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')
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);