From 6fbe4286eab576168b7f83b46207ad672de14de7 Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Thu, 13 Apr 2023 01:36:45 +0200 Subject: [PATCH] x11: Fix remaining leaks from switch to XGetAtomName() 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: e66f4396e ("x11: Avoid GDK API in X11 selections") Part-of: --- src/x11/meta-selection-source-x11.c | 4 +++- src/x11/meta-x11-selection.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/x11/meta-selection-source-x11.c b/src/x11/meta-selection-source-x11.c index 35451542b..a154b21af 100644 --- a/src/x11/meta-selection-source-x11.c +++ b/src/x11/meta-selection-source-x11.c @@ -155,7 +155,7 @@ atoms_to_mimetypes (MetaX11Display *display, for (i = 0; i < n_atoms; i++) { - const gchar *mimetype; + char *mimetype; meta_x11_error_trap_push (display); mimetype = XGetAtomName (xdisplay, atoms[i]); @@ -170,6 +170,8 @@ atoms_to_mimetypes (MetaX11Display *display, text_plain_found |= strcmp (mimetype, "text/plain") == 0; utf8_string_found |= strcmp (mimetype, "UTF8_STRING") == 0; string_found |= strcmp (mimetype, "STRING") == 0; + + XFree (mimetype); } /* Ensure non-x11 clients get well-known mimetypes */ diff --git a/src/x11/meta-x11-selection.c b/src/x11/meta-x11-selection.c index 0700fb506..66a1d1803 100644 --- a/src/x11/meta-x11-selection.c +++ b/src/x11/meta-x11-selection.c @@ -185,7 +185,7 @@ meta_x11_selection_find_target (MetaX11Display *x11_display, { Display *xdisplay = meta_x11_display_get_xdisplay (x11_display); GList* mimetypes = NULL; - const gchar *atom_name; + char *atom_name; char *retval; mimetypes = meta_selection_get_mimetypes (selection, selection_type); @@ -213,6 +213,7 @@ meta_x11_selection_find_target (MetaX11Display *x11_display, } g_list_free_full (mimetypes, g_free); + XFree (atom_name); return retval; }