From aa507417c29b3e3d499adcef99ac93318fd4b878 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Wed, 4 May 2022 16:37:32 -0500 Subject: [PATCH] xwm: Fix pasting in some cases I guess this reverts commit 73bdc0ce85583f65632d4de4b167295dbb06ee6d "xwm: Fix fd leak in weston_wm_send_data()" That commit closes the send half of a pipe in weston_wm_send_data, claiming that it's dup()licated later, and we'll leak the fd if we don't close it. That may have been true at the time? But currently that fd is only duplicated by wl_event_loop_add_fd() in its normal operation, and closing our original before that fd handler ever fires results in an EBADF on write, and the data never reaching its intended destination. Worse, by the time that handler is called there might be another use for that fd, and we could push data into it and close it. To provoke the problem, launch an app like FireFox over Xwayland, cut something to the clipboard, then close the app (this is the path where the wm has stored the clipboard contents and the app has gone away). relaunch it and paste the clipboard content back in. clipboard_client_data() will EBADF on write, and the data won't be pasted. Reported-by: Hideyuki Nagase Signed-off-by: Derek Foreman --- xwayland/selection.c | 1 - 1 file changed, 1 deletion(-) diff --git a/xwayland/selection.c b/xwayland/selection.c index b68988ec..0e4120ac 100644 --- a/xwayland/selection.c +++ b/xwayland/selection.c @@ -513,7 +513,6 @@ weston_wm_send_data(struct weston_wm *wm, xcb_atom_t target, const char *mime_ty source = seat->selection_data_source; source->send(source, mime_type, p[1]); - close(p[1]); } static void