From a7c7b0a8ef6483989d0a26c1ecff26082af9fed7 Mon Sep 17 00:00:00 2001 From: jenglish Date: Tue, 14 Jan 2003 19:23:55 +0000 Subject: * generic/tkSelect.c (Tk_CreateSelHandler): Fix for #666346 "Selection handling crashes under KDE 3.0" * tests/unixSelect.test (unixSelect-1.20): Added test case. --- ChangeLog | 5 +++++ generic/tkSelect.c | 9 +++++---- tests/unixSelect.test | 12 +++++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index cef9f0a..8a691b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-01-14 Joe English + * generic/tkSelect.c (Tk_CreateSelHandler): + Fix for #666346 "Selection handling crashes under KDE 3.0" + * tests/unixSelect.test (unixSelect-1.20): Added test case. + 2003-01-13 Mo DeJong * win/tkWinDialog.c (Tk_ChooseDirectoryObjCmd, diff --git a/generic/tkSelect.c b/generic/tkSelect.c index af98ccd..d62aa43 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.12 2002/08/31 06:12:26 das Exp $ + * RCS: @(#) $Id: tkSelect.c,v 1.13 2003/01/14 19:24:56 jenglish Exp $ */ #include "tkInt.h" @@ -200,9 +200,10 @@ Tk_CreateSelHandler(tkwin, selection, target, proc, clientData, format) * The clientData is selection controlled memory, so * we should make a copy for this selPtr. */ - selPtr->clientData = - (ClientData) ckalloc(sizeof(clientData)); - memcpy(selPtr->clientData, clientData, sizeof(clientData)); + unsigned cmdInfoLen = sizeof(CommandInfo) + + ((CommandInfo*)clientData)->cmdLength - 3; + selPtr->clientData = (ClientData)ckalloc(cmdInfoLen); + memcpy(selPtr->clientData, clientData, cmdInfoLen); } else { selPtr->clientData = clientData; } diff --git a/tests/unixSelect.test b/tests/unixSelect.test index efe11a8..ddbdc35 100644 --- a/tests/unixSelect.test +++ b/tests/unixSelect.test @@ -9,7 +9,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: unixSelect.test,v 1.7 2002/10/01 08:48:09 dkf Exp $ +# RCS: @(#) $Id: unixSelect.test,v 1.8 2003/01/14 19:24:51 jenglish Exp $ package require tcltest 2.1 namespace import -force tcltest::configure @@ -348,6 +348,16 @@ test unixSelect-1.19 {TkSelGetSelection procedure: INCR i18n text, utf-8} {unixO list [string equal i[string repeat [string repeat \u00c4\u00e4 50]\n 21] $x] \ [string length $x] [string bytelength $x] } {1 2122 4222} +test unixSelect-1.20 {Automatic UTF8_STRING support for selection handle} {unixOnly} { + # See Bug #666346 "Selection handling crashes under KDE 3.0" + label .l + selection handle .l [list handler STRING] + set selValue "This is the selection value" + selection own .l + set result [selection get -type UTF8_STRING] + destroy .l + set result +} "This is the selection value" # cleanup ::tcltest::cleanupTests -- cgit v0.12