wayland: Be more careful with mimetypes

Sometimes, jokers send us 'mimetypes' like DELETE or
org.webkitgtk.WebKit.custom-pasteboard-data, and gdk_intern_mime_type
will return NULL for such things. Handle that by just closing the fd.

Better than running into an assertion further down.
This commit is contained in:
Matthias Clasen 2024-09-22 01:02:59 +02:00
parent cc867eeccf
commit b623b2acef
3 changed files with 19 additions and 2 deletions

View File

@ -110,6 +110,12 @@ gdk_wayland_clipboard_data_source_send (void *data,
source, mime_type, fd);
mime_type = gdk_intern_mime_type (mime_type);
if (!mime_type)
{
close (fd);
return;
}
stream = g_unix_output_stream_new (fd, TRUE);
gdk_clipboard_write_async (GDK_CLIPBOARD (cb),

View File

@ -250,8 +250,13 @@ data_source_send (void *data,
"%p: data source send request for %s on fd %d\n",
source, mime_type, fd);
//mime_type = gdk_intern_mime_type (mime_type);
mime_type = g_intern_string (mime_type);
mime_type = gdk_intern_mime_type (mime_type);
if (!mime_type)
{
close (fd);
return;
}
stream = g_unix_output_stream_new (fd, TRUE);
gdk_drag_write_async (drag,

View File

@ -227,6 +227,12 @@ gdk_wayland_primary_data_source_send (void *da
source, mime_type, fd);
mime_type = gdk_intern_mime_type (mime_type);
if (!mime_type)
{
close (fd);
return;
}
stream = g_unix_output_stream_new (fd, TRUE);
gdk_clipboard_write_async (GDK_CLIPBOARD (cb),