summaryrefslogtreecommitdiffstats
path: root/generic/tkSelect.c
diff options
context:
space:
mode:
authordonal.k.fellows@manchester.ac.uk <dkf>2005-11-22 11:32:35 (GMT)
committerdonal.k.fellows@manchester.ac.uk <dkf>2005-11-22 11:32:35 (GMT)
commitef05f05941ed431da946ecd0c6b0ee956ac82796 (patch)
treea90c2e014e2a1d92cda19a88347eaa9f722e56f2 /generic/tkSelect.c
parentc8617509f116942ea17b2c9ebcf63794e226242c (diff)
downloadtk-ef05f05941ed431da946ecd0c6b0ee956ac82796.zip
tk-ef05f05941ed431da946ecd0c6b0ee956ac82796.tar.gz
tk-ef05f05941ed431da946ecd0c6b0ee956ac82796.tar.bz2
Backport of fixes for [Bug 1353414]
Diffstat (limited to 'generic/tkSelect.c')
-rw-r--r--generic/tkSelect.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/generic/tkSelect.c b/generic/tkSelect.c
index d62aa43..73e41d8 100644
--- a/generic/tkSelect.c
+++ b/generic/tkSelect.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkSelect.c,v 1.13 2003/01/14 19:24:56 jenglish Exp $
+ * RCS: @(#) $Id: tkSelect.c,v 1.13.2.1 2005/11/22 11:32:37 dkf Exp $
*/
#include "tkInt.h"
@@ -1489,29 +1489,32 @@ TkSelDefaultSelection(infoPtr, target, buffer, maxBytes, typePtr)
if (target == dispPtr->targetsAtom) {
register TkSelHandler *selPtr;
- CONST char *atomString;
- int length, atomLength;
+ int length;
+ Tcl_DString ds;
if (maxBytes < 50) {
return -1;
}
- strcpy(buffer, "MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW");
- length = strlen(buffer);
+ Tcl_DStringInit(&ds);
+ Tcl_DStringAppend(&ds,
+ "MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW", -1);
for (selPtr = winPtr->selHandlerList; selPtr != NULL;
selPtr = selPtr->nextPtr) {
if ((selPtr->selection == infoPtr->selection)
&& (selPtr->target != dispPtr->applicationAtom)
&& (selPtr->target != dispPtr->windowAtom)) {
- atomString = Tk_GetAtomName((Tk_Window) winPtr,
+ CONST char *atomString = Tk_GetAtomName((Tk_Window) winPtr,
selPtr->target);
- atomLength = strlen(atomString) + 1;
- if ((length + atomLength) >= maxBytes) {
- return -1;
- }
- sprintf(buffer+length, " %s", atomString);
- length += atomLength;
+ Tcl_DStringAppendElement(&ds, atomString);
}
}
+ length = Tcl_DStringLength(&ds);
+ if (length >= maxBytes) {
+ Tcl_DStringFree(&ds);
+ return -1;
+ }
+ memcpy(buffer, Tcl_DStringValue(&ds), (unsigned) (1+length));
+ Tcl_DStringFree(&ds);
*typePtr = XA_ATOM;
return length;
}