summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclCmdIL.c23
2 files changed, 18 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index b095a5c..af595f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-10 Miguel Sofer <msofer@users.sf.net>
+
+ * generic/tclCmdIL (Tcl_LsortObjCmd): changed fix to [Bug 1675116]
+ to use the cheaper TclListObjCopy() instead of Tcl_DuplicateObj()
+
2007-03-09 Andreas Kupries <andreask@activestate.com>
* library/platform/shell.tcl: Made more robust if an older platform
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,