From 5e017044f69ffb821be678964764a4bfb19afe8b Mon Sep 17 00:00:00 2001
From: Ulrich Sibiller <uli42@gmx.de>
Date: Fri, 18 Jun 2021 00:06:57 +0200
Subject: Clipboard.c: do not process requests if we do not have a local owner

This can happen after having processed a SelectionClear event while
the real X server still knows the nxagent serverWindow as the
selection owner.
---
 nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 9 +++++++++
 1 file changed, 9 insertions(+)

(limited to 'nx-X11')

diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
index c200ad64c..018827a0a 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c
@@ -995,6 +995,15 @@ void nxagentHandleSelectionRequestFromXServer(XEvent *X)
     return;
   }
 
+  if (!IS_LOCAL_OWNER(index))
+  {
+    #ifdef DEBUG
+    fprintf(stderr, "%s: no local owner for selection [%ld] - denying request.\n", __func__, X->xselectionrequest.selection);
+    #endif
+    replyRequestSelectionToXServer(X, False);
+    return;
+  }
+
   #ifdef DEBUG
   fprintf(stderr, "%s: lastServers[%d].requestor [0x%lx].\n", __func__, index, lastServers[index].requestor);
   #endif
-- 
cgit v1.2.3