]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix crash with outdated selection requests
authorPo Lu <luangruo@yahoo.com>
Wed, 8 Jun 2022 02:54:07 +0000 (10:54 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 8 Jun 2022 02:54:07 +0000 (10:54 +0800)
* src/xselect.c (x_handle_selection_request): Don't store into
stack if it wasn't previously pushed.

src/xselect.c

index 0271310d04232f552db3c0d6c5805b6941d79b92..d184489cbd83c965028ecc730561f02dea840400 100644 (file)
@@ -762,7 +762,6 @@ static void
 x_handle_selection_request (struct selection_input_event *event)
 {
   Time local_selection_time;
-
   struct x_display_info *dpyinfo = SELECTION_EVENT_DPYINFO (event);
   Atom selection = SELECTION_EVENT_SELECTION (event);
   Lisp_Object selection_symbol = x_atom_to_symbol (dpyinfo, selection);
@@ -772,8 +771,12 @@ x_handle_selection_request (struct selection_input_event *event)
   Lisp_Object local_selection_data;
   bool success = false;
   specpdl_ref count = SPECPDL_INDEX ();
+  bool pushed;
+
+  pushed = false;
 
-  if (!dpyinfo) goto DONE;
+  if (!dpyinfo)
+    goto DONE;
 
   /* This is how the XDND protocol recommends dropping text onto a
      target that doesn't support XDND.  */
@@ -794,6 +797,7 @@ x_handle_selection_request (struct selection_input_event *event)
     goto DONE;
 
   block_input ();
+  pushed = true;
   x_push_current_selection_request (event, dpyinfo);
   record_unwind_protect_void (x_pop_current_selection_request);
   record_unwind_protect_void (x_selection_request_lisp_error);
@@ -854,7 +858,8 @@ x_handle_selection_request (struct selection_input_event *event)
 
  DONE:
 
-  selection_request_stack->converted = true;
+  if (pushed)
+    selection_request_stack->converted = true;
 
   if (success)
     x_reply_selection_request (event, dpyinfo);