From e0dfc14983c3b873f4de465bf55bdf2de0e106ba Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Fri, 29 Jan 2021 18:24:08 -0500 Subject: [PATCH] xwayland/selection: don't request another selection while one is pending This will hopefully be fixed in the future by having separate windows for each X11-to-Wayland transfer, but until then, let's avoid a compositor crash. --- xwayland/selection/incoming.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/xwayland/selection/incoming.c b/xwayland/selection/incoming.c index 91ab7767..c5aa783e 100644 --- a/xwayland/selection/incoming.c +++ b/xwayland/selection/incoming.c @@ -150,6 +150,21 @@ static void source_send(struct wlr_xwm_selection *selection, return; } + // FIXME: we currently can't handle two X11-to-Wayland transfers at once due + // to reusing the same X11 window. Proceeding further here would lead us to + // lose track of the current `transfer->wl_client_fd` and use-after-free + // during cleanup. This doesn't happen often, but bail now to avoid a + // compositor crash later. + if (transfer->wl_client_fd > 0) { + wlr_log(WLR_ERROR, "source_send fd %d, but %d already in progress", fd, + transfer->wl_client_fd); + if (transfer->wl_client_fd != fd) { + close(fd); + } + + return; + } + xcb_convert_selection(xwm->xcb_conn, selection->window, selection->atom,