x11: Push error trap reading X11 selection

It is a possibility that this request results in an error, so handle
the possible fallout.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2745>
This commit is contained in:
Carlos Garnacho 2022-12-06 15:08:47 +01:00
parent 8789e1b7d9
commit 5816268c1d

View File

@ -341,11 +341,11 @@ XFree_without_return_value (gpointer data)
}
static GBytes *
get_selection_property (Display *xdisplay,
Window owner,
Atom property,
Atom *ret_type,
gint *ret_format)
get_selection_property (MetaX11Display *x11_display,
Window owner,
Atom property,
Atom *ret_type,
gint *ret_format)
{
gulong nitems;
gulong nbytes;
@ -353,10 +353,18 @@ get_selection_property (Display *xdisplay,
gint prop_format;
uint8_t *data = NULL;
if (XGetWindowProperty (xdisplay, owner, property,
meta_x11_error_trap_push (x11_display);
if (XGetWindowProperty (x11_display->xdisplay, owner, property,
0, 0x1FFFFFFF, False,
AnyPropertyType, &prop_type, &prop_format,
&nitems, &nbytes, &data) != Success)
{
meta_x11_error_trap_pop (x11_display);
goto err;
}
if (meta_x11_error_trap_pop_with_return (x11_display) != Success)
goto err;
if (prop_type != None)
@ -426,7 +434,8 @@ meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream,
xevent->xproperty.state != PropertyNewValue)
return FALSE;
bytes = get_selection_property (xdisplay, xwindow, xevent->xproperty.atom,
bytes = get_selection_property (priv->x11_display, xwindow,
xevent->xproperty.atom,
&type, &format);
if (bytes == NULL)
@ -477,7 +486,7 @@ meta_x11_selection_input_stream_xevent (MetaX11SelectionInputStream *stream,
}
else
{
bytes = get_selection_property (xdisplay, xwindow,
bytes = get_selection_property (priv->x11_display, xwindow,
xevent->xselection.property,
&priv->xtype, &priv->format);
priv->type = gdk_x11_get_xatom_name (priv->xtype);