summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2007-03-10 15:24:25 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2007-03-10 15:24:25 (GMT)
commit710dd21450365fc5bb3612c570587dd02119795d (patch)
tree7cec4e426ac93d389984743952a3dc7e8bf81f43 /generic
parente0efa747c2cefb29ffa4c46bf1c0d8b3923bd600 (diff)
downloadtcl-710dd21450365fc5bb3612c570587dd02119795d.zip
tcl-710dd21450365fc5bb3612c570587dd02119795d.tar.gz
tcl-710dd21450365fc5bb3612c570587dd02119795d.tar.bz2
* generic/tclCmdIL (Tcl_LsortObjCmd): changed fix to [Bug 1675116]
to use the cheaper TclListObjCopy() instead of Tcl_DuplicateObj()
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdIL.c23
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,