Index: /trunk/include/VBox/GuestHost/SharedClipboard-x11.h
===================================================================
--- /trunk/include/VBox/GuestHost/SharedClipboard-x11.h	(revision 102467)
+++ /trunk/include/VBox/GuestHost/SharedClipboard-x11.h	(revision 102468)
@@ -168,4 +168,19 @@
 
 /**
+ * Enumeration for an X11 event type.
+ */
+typedef enum _SHCLX11EVENTTYPE
+{
+    /** Invalid event type. */
+    SHCLX11EVENTTYPE_INVALID = 0,
+    /** Reports formats to X11. */
+    SHCLX11EVENTTYPE_REPORT_FORMATS,
+    /** Reads clipboard from X11. */
+    SHCLX11EVENTTYPE_READ
+} SHCLX11EVENTTYPE;
+/** Pointer to an enumeration for an X11 event type. */
+typedef SHCLX11EVENTTYPE *PSHCLX11EVENTTYPE;
+
+/**
  * Structure describing an X11 clipboard request.
  */
@@ -176,4 +191,6 @@
     /** Event associated to this request. */
     PSHCLEVENT       pEvent;
+    /** Request type for the union below. */
+    SHCLX11EVENTTYPE enmType;
     union
     {
@@ -204,10 +221,16 @@
 typedef struct _SHCLX11RESPONSE
 {
-    int rc;
-    struct
+    /** Response type for the union below. */
+    SHCLX11EVENTTYPE enmType;
+    /** rc (IPRT-style) of the operation performed as part of the X event thread. */
+    int              rc;
+    union
     {
-        void    *pvData;
-        uint32_t cbData;
-    } Read;
+        struct
+        {
+            void    *pvData;
+            uint32_t cbData;
+        } Read;
+    };
 } SHCLX11RESPONSE;
 /** Pointer to an X11 clipboard response. */
Index: /trunk/src/VBox/Additions/x11/VBoxClient/clipboard-x11.cpp
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/clipboard-x11.cpp	(revision 102467)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/clipboard-x11.cpp	(revision 102468)
@@ -93,6 +93,8 @@
                         if (pPayload)
                         {
-                            Assert(pPayload->cbData == sizeof(SHCLX11RESPONSE));
+                            AssertReturnVoid(pPayload->cbData == sizeof(SHCLX11RESPONSE));
+                            AssertReturnVoid(pPayload->pvData);
                             PSHCLX11RESPONSE pResp = (PSHCLX11RESPONSE)pPayload->pvData;
+                            AssertReturnVoid(pResp->enmType == SHCLX11EVENTTYPE_READ);
 
                             rc = ShClTransferRootsInitFromStringListEx(pTransfer, (const char *)pResp->Read.pvData, pResp->Read.cbData,
@@ -559,6 +561,8 @@
                                 if (pPayload)
                                 {
-                                    Assert(pPayload->cbData == sizeof(SHCLX11RESPONSE));
+                                    AssertBreakStmt(pPayload->cbData == sizeof(SHCLX11RESPONSE), rc = VERR_INVALID_PARAMETER);
+                                    AssertPtrBreakStmt(pPayload->pvData, rc = VERR_INVALID_POINTER);
                                     PSHCLX11RESPONSE pResp = (PSHCLX11RESPONSE)pPayload->pvData;
+                                    AssertBreakStmt(pResp->enmType == SHCLX11EVENTTYPE_READ, rc = VERR_INVALID_PARAMETER);
 
                                     rc = VbglR3ClipboardWriteDataEx(&pCtx->CmdCtx, pEvent->u.fReadData,
Index: /trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
===================================================================
--- /trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp	(revision 102467)
+++ /trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp	(revision 102468)
@@ -1980,4 +1980,5 @@
 
     PSHCLX11REQUEST pReq = (PSHCLX11REQUEST)pvUserData;
+    AssertReturnVoid(pReq->enmType == SHCLX11EVENTTYPE_REPORT_FORMATS);
 
     PSHCLX11CTX pCtx     = pReq->pCtx;
@@ -2020,4 +2021,5 @@
     if (pReq)
     {
+        pReq->enmType          = SHCLX11EVENTTYPE_REPORT_FORMATS;
         pReq->pCtx             = pCtx;
         pReq->Formats.fFormats = uFormats;
@@ -2121,4 +2123,5 @@
 
     /* Sanity. */
+    AssertReturnVoid(pReq->enmType == SHCLX11EVENTTYPE_READ);
     AssertReturnVoid(pReq->Read.uFmtVBox != VBOX_SHCL_FMT_NONE);
     AssertReturnVoid(pReq->Read.idxFmtX11 < SHCL_MAX_X11_FORMATS);
@@ -2379,4 +2382,5 @@
         if (pReq) /* Give some more clues, if available. */
         {
+            AssertReturnVoid(pReq->enmType == SHCLX11EVENTTYPE_READ);
             char *pszFmts = ShClFormatsToStrA(pReq->Read.uFmtVBox);
             AssertPtrReturnVoid(pszFmts);
@@ -2475,4 +2479,5 @@
 
     PSHCLX11REQUEST   pReq = (PSHCLX11REQUEST)pvUserData;
+    AssertReturnVoid(pReq->enmType == SHCLX11EVENTTYPE_READ);
     SHCLX11CTX       *pCtx = pReq->pCtx;
     AssertPtrReturnVoid(pCtx);
@@ -2582,4 +2587,5 @@
     if (pReq)
     {
+        pReq->enmType       = SHCLX11EVENTTYPE_READ;
         pReq->pCtx          = pCtx;
         pReq->Read.uFmtVBox = uFmt;
@@ -2636,6 +2642,8 @@
                 if (pPayload)
                 {
-                    Assert(pPayload->cbData == sizeof(SHCLX11RESPONSE));
+                    AssertReturn(pPayload->cbData == sizeof(SHCLX11RESPONSE), VERR_INVALID_PARAMETER);
+                    AssertPtrReturn(pPayload->pvData, VERR_INVALID_POINTER);
                     PSHCLX11RESPONSE pResp = (PSHCLX11RESPONSE)pPayload->pvData;
+                    AssertReturn(pResp->enmType == SHCLX11EVENTTYPE_READ, VERR_INVALID_PARAMETER);
 
                     memcpy(pvBuf, pResp->Read.pvData, RT_MIN(cbBuf, pResp->Read.cbData));
Index: /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp	(revision 102467)
+++ /trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp	(revision 102468)
@@ -307,6 +307,8 @@
                 if (pPayload)
                 {
-                    Assert(pPayload->cbData == sizeof(SHCLX11RESPONSE));
+                    AssertReturn(pPayload->cbData == sizeof(SHCLX11RESPONSE), VERR_INVALID_PARAMETER);
+                    AssertPtrReturn(pPayload->pvData, VERR_INVALID_POINTER);
                     PSHCLX11RESPONSE pResp = (PSHCLX11RESPONSE)pPayload->pvData;
+                    AssertReturn(pResp->enmType == SHCLX11EVENTTYPE_READ, VERR_INVALID_PARAMETER);
 
                     uint32_t const cbRead = pResp->Read.cbData;
@@ -732,7 +734,8 @@
                 if (pPayload)
                 {
-                    Assert(pPayload->cbData == sizeof(SHCLX11RESPONSE));
-                    AssertPtr(pPayload->pvData);
+                    AssertReturn(pPayload->cbData == sizeof(SHCLX11RESPONSE), VERR_INVALID_PARAMETER);
+                    AssertPtrReturn(pPayload->pvData, VERR_INVALID_POINTER);
                     PSHCLX11RESPONSE pResp = (PSHCLX11RESPONSE)pPayload->pvData;
+                    AssertReturn(pResp->enmType == SHCLX11EVENTTYPE_READ, VERR_INVALID_PARAMETER);
 
                     rc = ShClTransferRootsInitFromStringList(pCtx->pTransfer,
