mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-13 04:51:15 +00:00
file-operation: Return early when basename is NULL
Calling g_utf8_validate() on a NULL string crashes Nautilus. This can occur if performing an operation on an invalid file. If basename is NULL, there's nothing we would do anyways, so just return early and prevent the crash. There's a similar issue with get_unique_target_file(), but if a bad uri was passed to this function it should fail much earlier, so lets just add an assertion. Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2376
This commit is contained in:
parent
b34ea39892
commit
e2969a9c29
|
@ -1022,6 +1022,11 @@ get_basename (GFile *file)
|
|||
if (name == NULL)
|
||||
{
|
||||
basename = g_file_get_basename (file);
|
||||
if (basename == NULL)
|
||||
{
|
||||
return g_strdup (_("unknown"));
|
||||
}
|
||||
|
||||
if (g_utf8_validate (basename, -1, NULL))
|
||||
{
|
||||
name = basename;
|
||||
|
@ -4384,6 +4389,7 @@ get_unique_target_file (GFile *src,
|
|||
if (dest == NULL)
|
||||
{
|
||||
basename = g_file_get_basename (src);
|
||||
g_assert (basename == NULL);
|
||||
|
||||
if (g_utf8_validate (basename, -1, NULL))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue