wayland: Don't leak XDnD mime type strings

After this got changed from gdk_x11_get_xatom_name() to XGetAtomName(),
this no longer returns a const char* and it now also needs to be freed.

Fixes: 014cde646 ("wayland: Do not use GDK functions on XDnD implementation")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
This commit is contained in:
Sebastian Keller 2023-04-12 23:27:41 +02:00 committed by Marge Bot
parent 47b6e76578
commit 5a4b67dd9e

View File

@ -737,7 +737,7 @@ meta_xwayland_data_source_fetch_mimetype_list (MetaWaylandDataSource *source,
for (i = 0; i < nitems_ret; i++) for (i = 0; i < nitems_ret; i++)
{ {
const gchar *mime_type; char *mime_type;
if (atoms[i] == utf8_string) if (atoms[i] == utf8_string)
{ {
@ -748,6 +748,7 @@ meta_xwayland_data_source_fetch_mimetype_list (MetaWaylandDataSource *source,
mime_type = XGetAtomName (xdisplay, atoms[i]); mime_type = XGetAtomName (xdisplay, atoms[i]);
meta_wayland_data_source_add_mime_type (source, mime_type); meta_wayland_data_source_add_mime_type (source, mime_type);
XFree (mime_type);
} }
XFree (atoms); XFree (atoms);
@ -933,7 +934,7 @@ meta_xwayland_dnd_handle_client_message (MetaWaylandCompositor *compositor,
if (!(event->data.l[1] & 1)) if (!(event->data.l[1] & 1))
{ {
/* Mimetypes are contained in this message */ /* Mimetypes are contained in this message */
const gchar *mimetype; char *mimetype;
gint i; gint i;
struct wl_array *source_mime_types; struct wl_array *source_mime_types;
@ -950,6 +951,7 @@ meta_xwayland_dnd_handle_client_message (MetaWaylandCompositor *compositor,
mimetype = XGetAtomName (xdisplay, event->data.l[i]); mimetype = XGetAtomName (xdisplay, event->data.l[i]);
meta_wayland_data_source_add_mime_type (dnd->source, meta_wayland_data_source_add_mime_type (dnd->source,
mimetype); mimetype);
XFree (mimetype);
} }
} }
} }