summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdIL.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclCmdIL.c')
-rw-r--r--generic/tclCmdIL.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index d44ba7a..85e51d0 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -15,7 +15,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.47.2.10 2006/11/28 22:20:00 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.47.2.11 2007/03/10 14:57:38 dkf Exp $
*/
#include "tclInt.h"
@@ -3799,6 +3799,15 @@ Tcl_LsortObjCmd(clientData, interp, objc, objv)
elementArray[i].objPtr = listObjPtrs[i];
elementArray[i].count = 0;
elementArray[i].nextPtr = &elementArray[i+1];
+
+ /*
+ * 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. Increment the reference counts of the elements
+ * to sort to prevent this. [Bug 1675116]
+ */
+
+ Tcl_IncrRefCount(elementArray[i].objPtr);
}
elementArray[length-1].nextPtr = NULL;
elementPtr = MergeSort(elementArray, &sortInfo);
@@ -3824,6 +3833,9 @@ Tcl_LsortObjCmd(clientData, interp, objc, objv)
}
}
}
+ for (i=0; i<length; i++) {
+ Tcl_DecrRefCount(elementArray[i].objPtr);
+ }
ckfree((char*) elementArray);
done: