emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d1c6193720: Fix crash with outdated selection requests


From: Po Lu
Subject: master d1c6193720: Fix crash with outdated selection requests
Date: Tue, 7 Jun 2022 22:54:18 -0400 (EDT)

branch: master
commit d1c619372099ba123b7aa485907ed71ec961e9fe
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix crash with outdated selection requests
    
    * src/xselect.c (x_handle_selection_request): Don't store into
    stack if it wasn't previously pushed.
---
 src/xselect.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/xselect.c b/src/xselect.c
index 0271310d04..d184489cbd 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -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);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]