diff options
author | dkf <dkf@noemail.net> | 2005-11-14 16:29:14 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2005-11-14 16:29:14 (GMT) |
commit | b12a091fbf1b61b954b792d2957c36840632ddbf (patch) | |
tree | 88b8d41f5508e209e7ff60472aba0064ce1ee4c5 | |
parent | fd4e7ceea1eee83e5aca50d8a764120f5ec0fc60 (diff) | |
download | tk-b12a091fbf1b61b954b792d2957c36840632ddbf.zip tk-b12a091fbf1b61b954b792d2957c36840632ddbf.tar.gz tk-b12a091fbf1b61b954b792d2957c36840632ddbf.tar.bz2 |
Fix problem in default selection handler outlined by test select-9.5
FossilOrigin-Name: 86521c09de741088f352649b261bb012b66372e6
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tkSelect.c | 26 |
2 files changed, 19 insertions, 12 deletions
@@ -1,3 +1,8 @@ +2005-11-14 Donal K. Fellows <donal.k.fellows@manchester.ac.uk> + + * generic/tkSelect.c (TkSelDefaultSelection): Test select-9.5 + highlighted further brokenness in this function. + 2005-11-13 Donal K. Fellows <donal.k.fellows@manchester.ac.uk> * unix/tkUnixSelect.c (SelCvtToX): Arrange for the parsing code to diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 396237e..a12bcc2 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -10,7 +10,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.16 2005/10/17 22:02:44 dkf Exp $ + * RCS: @(#) $Id: tkSelect.c,v 1.17 2005/11/14 16:29:15 dkf Exp $ */ #include "tkInt.h" @@ -1479,29 +1479,31 @@ TkSelDefaultSelection( 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) { + return -1; + } + memcpy(buffer, Tcl_DStringValue(&ds), (unsigned) (1+length)); + Tcl_DStringFree(&ds); *typePtr = XA_ATOM; return length; } |