shell-mime-sniffer: Ignore invalid file content type
The shell mime sniffer goes through all the files in a directory,
however in case a file content type is not recognized, the GIO function
g_file_info_get_content_type() may return NULL, causing a crash when
looking up into the content type tables, as they are supposed to contain
strings only and they use `g_str_hash` has func, which doesn't support
NULL values.
So, in case we get an invalid content type, let's just ignore it,
without adding it to the cache as we do in the nautilus code that was
inspiring the sniffer.
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2643
(cherry picked from commit 46547ae027
)
This commit is contained in:
parent
b642f9275e
commit
ff73f76527
@ -253,6 +253,8 @@ deep_count_one (DeepCountState *state,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
content_type = g_file_info_get_content_type (info);
|
content_type = g_file_info_get_content_type (info);
|
||||||
|
|
||||||
|
if (content_type)
|
||||||
add_content_type_to_cache (state, content_type);
|
add_content_type_to_cache (state, content_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user