From d1c619372099ba123b7aa485907ed71ec961e9fe Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 8 Jun 2022 10:54:07 +0800 Subject: [PATCH] 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 0271310d042..d184489cbd8 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); -- 2.39.2