]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix potential crash deselecting for property change notifications
authorPo Lu <luangruo@yahoo.com>
Sun, 4 Dec 2022 13:54:52 +0000 (21:54 +0800)
committerPo Lu <luangruo@yahoo.com>
Sun, 4 Dec 2022 13:56:23 +0000 (21:56 +0800)
* src/xselect.c (x_cancel_selection_transfer): Catch errors
around XSelectInput.

src/xselect.c

index 120a5a163e206b73feec212020579f06701be10f..121b17df1b053da13fbb3a2657883b337f10a8c4 100644 (file)
@@ -794,8 +794,16 @@ x_cancel_selection_transfer (struct transfer *transfer)
                                    transfer->requestor)
       /* This can be called from x_delete_display.  */
       && transfer->dpyinfo->display)
-    XSelectInput (transfer->dpyinfo->display,
-                 transfer->requestor, NoEventMask);
+    {
+      /* Ignore errors generated by the change window request in case
+        the window has gone away.  */
+      block_input ();
+      x_ignore_errors_for_next_request (transfer->dpyinfo);
+      XSelectInput (transfer->dpyinfo->display,
+                   transfer->requestor, NoEventMask);
+      x_stop_ignoring_errors (transfer->dpyinfo);
+      unblock_input ();
+    }
 
   cancel_atimer (transfer->timeout);
   xfree (transfer);