Index: winclipboardxevents.c
===================================================================
RCS file: /cvsroot/xoncygwin/xc/programs/Xserver/hw/xwin/winclipboardxevents.c,v
retrieving revision 1.2
diff -u -r1.2 winclipboardxevents.c
--- winclipboardxevents.c	15 Sep 2003 18:14:05 -0000	1.2
+++ winclipboardxevents.c	6 Oct 2003 17:42:43 -0000
@@ -68,6 +68,8 @@
   char			**ppszTextList = NULL;
   wchar_t		*pwszUnicodeStr = NULL;
   int			iUnicodeLen = 0;
+  int			iReturnDataLen = 0;
+  int			i;
 
   /* Process all pending events */
   while (XPending (pDisplay))
@@ -547,28 +549,59 @@
 	      char		*pszAtomName = NULL;
 
 	      ErrorF ("SelectionNotify - returned data %d left %d\n",
-		      prop.nitems, ulReturnBytesLeft);
+		      xtpText.nitems, ulReturnBytesLeft);
 	      
-	      pszAtomName = XGetAtomName(pDisplay, prop.encoding);
+	      pszAtomName = XGetAtomName(pDisplay, xtpText.encoding);
 	      ErrorF ("Notify atom name %s\n", pszAtomName);
 	      XFree (pszAtomName);
 	      pszAtomName = NULL;
 #endif
 	      
 	      /* Convert the text property to a text list */
-	      Xutf8TextPropertyToTextList (pDisplay,
-					   &xtpText,
-					   &ppszTextList,
-					   &iCount);
-	      if (iCount > 0)
+	      iReturn = Xutf8TextPropertyToTextList (pDisplay,
+						     &xtpText,
+						     &ppszTextList,
+						     &iCount);
+	      if (iReturn == Success || iReturn > 0)
 		{
-		  pszReturnData = malloc (strlen (ppszTextList[0]) + 1);
-		  strcpy (pszReturnData, ppszTextList[0]);
+		  /* Conversion succeeded or some unconvertible characters */
+		  if (ppszTextList != NULL)
+		    {
+		      for (i = 0; i < iCount; i++)
+			{
+			  iReturnDataLen += strlen(ppszTextList[i]);
+			}
+		      pszReturnData = malloc (iReturnDataLen + 1);
+		      pszReturnData[0] = '\0';
+		      for (i = 0; i < iCount; i++)
+			{
+			  strcat (pszReturnData, ppszTextList[i]);
+			}
+		    }
+		  else
+		    {
+		      ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+			      "Xutf8TextPropertyToTextList list_return is NULL\n");
+		      pszReturnData = malloc (1);
+		      pszReturnData[0] = '\0';
+		    }
 		}
 	      else
 		{
+		  switch (iReturn)
+		    {
+		    case XNoMemory:
+		      ErrorF ("winClipboardFlushXEvents - SelectionNotify - XNoMemory\n");
+		      break;
+		    case XConverterNotFound:
+		      ErrorF ("winClipboardFlushXEvents - SelectionNotify - XConverterNotFound\n");
+		      break;
+		    default:
+		      ErrorF ("winClipboardFlushXEvents - SelectionNotify - Unknown Error\n");
+		      break;
+		    }
 		  pszReturnData = malloc (1);
-		  pszReturnData[0] = 0;
+		  pszReturnData[0] = '\0';
 		}
 	      
 	      /* Free the data returned from XGetWindowProperty */
