diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclCmdIL.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index e71f043..94b18b7 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -16,7 +16,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdIL.c,v 1.109 2007/03/09 16:40:21 dkf Exp $ + * RCS: @(#) $Id: tclCmdIL.c,v 1.110 2007/03/10 15:24:26 msofer Exp $ */ #include "tclInt.h" @@ -4002,6 +4002,18 @@ Tcl_LsortObjCmd( if (sortInfo.sortMode == SORTMODE_COMMAND) { /* + * When sorting using a command, we are reentrant and therefore might + * have the representation of the list being sorted shimmered out from + * underneath our feet. Take a copy (cheap) to prevent this. [Bug + * 1675116] + */ + + listObj = TclListObjCopy(interp,listObj); + if (listObj == NULL) { + return TCL_ERROR; + } + + /* * The existing command is a list. We want to flatten it, append two * dummy arguments on the end, and replace these arguments later. */ @@ -4022,15 +4034,6 @@ Tcl_LsortObjCmd( } Tcl_ListObjAppendElement(interp, newCommandPtr, Tcl_NewObj()); sortInfo.compareCmdPtr = newCommandPtr; - - /* - * When sorting using a command, we are reentrant and therefore might - * have the representation of the list being sorted shimmered out from - * underneath our feet. Take a copy (cheap) to prevent this. [Bug - * 1675116] - */ - - listObj = Tcl_DuplicateObj(listObj); } sortInfo.resultCode = Tcl_ListObjGetElements(interp, listObj, |