From c79e0188e849715a7c4dc306c93ad8d0b3517d32 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 19 Mar 2022 18:46:50 +0800 Subject: [PATCH] Improve protection against faulty clients during DND * src/xterm.c (x_dnd_send_enter, x_dnd_send_position) (xdnd_send_leave, x_dnd_send_drop): Catch errors around call to XSendEvent. The target window could be gone. --- src/xterm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/xterm.c b/src/xterm.c index b820c102f1b..fb0fc66ae59 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -1035,7 +1035,9 @@ x_dnd_send_enter (struct frame *f, Window target, int supported) PropModeReplace, (unsigned char *) x_dnd_targets, x_dnd_n_targets); + x_catch_errors (dpyinfo->display); XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg); + x_uncatch_errors (); } static void @@ -1075,7 +1077,9 @@ x_dnd_send_position (struct frame *f, Window target, int supported, if (supported >= 4) msg.xclient.data.l[4] = action; + x_catch_errors (dpyinfo->display); XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg); + x_uncatch_errors (); } static void @@ -1094,7 +1098,9 @@ x_dnd_send_leave (struct frame *f, Window target) msg.xclient.data.l[3] = 0; msg.xclient.data.l[4] = 0; + x_catch_errors (dpyinfo->display); XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg); + x_uncatch_errors (); } static void @@ -1117,7 +1123,9 @@ x_dnd_send_drop (struct frame *f, Window target, Time timestamp, if (supported >= 1) msg.xclient.data.l[2] = timestamp; + x_catch_errors (dpyinfo->display); XSendEvent (FRAME_X_DISPLAY (f), target, False, 0, &msg); + x_uncatch_errors (); } void -- 2.39.2