summaryrefslogtreecommitdiffstats
path: root/generic/tclListObj.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2013-01-30 08:19:22 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2013-01-30 08:19:22 (GMT)
commit52368789306fda3ae17cf554333fa3adb617ba0a (patch)
tree10729608c91275933e64387693a867743563aab0 /generic/tclListObj.c
parentbc3ea33b9b409c840682f5feb2b4efb4c78029f8 (diff)
parent75972077579a3e9bf1363e817260d11f17d60266 (diff)
downloadtcl-novem_no_startcmd.zip
tcl-novem_no_startcmd.tar.gz
tcl-novem_no_startcmd.tar.bz2
merge changes from trunknovem_no_startcmd
Diffstat (limited to 'generic/tclListObj.c')
-rw-r--r--generic/tclListObj.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 3668b45..2d1defa 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -909,6 +909,10 @@ Tcl_ListObjReplace(
isShared = (listRepPtr->refCount > 1);
numRequired = numElems - count + objc;
+ for (i = 0; i < objc; i++) {
+ Tcl_IncrRefCount(objv[i]);
+ }
+
if ((numRequired <= listRepPtr->maxElemCount) && !isShared) {
int shift;
@@ -963,6 +967,14 @@ Tcl_ListObjReplace(
if (listRepPtr == NULL) {
listRepPtr = AttemptNewList(interp, numRequired, NULL);
if (listRepPtr == NULL) {
+ for (i = 0; i < objc; i++) {
+ /* See bug 3598580 */
+#if TCL_MAJOR_VERSION > 8
+ Tcl_DecrRefCount(objv[i]);
+#else
+ objv[i]->refCount--;
+#endif
+ }
return TCL_ERROR;
}
}
@@ -1027,14 +1039,11 @@ Tcl_ListObjReplace(
}
/*
- * Insert the new elements into elemPtrs before "first". We don't do a
- * memcpy here because we must increment the reference counts for the
- * added elements, so we must explicitly loop anyway.
+ * Insert the new elements into elemPtrs before "first".
*/
for (i=0,j=first ; i<objc ; i++,j++) {
elemPtrs[j] = objv[i];
- Tcl_IncrRefCount(objv[i]);
}
/*