summaryrefslogtreecommitdiffstats
path: root/generic/tclListObj.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2013-01-02 18:35:39 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2013-01-02 18:35:39 (GMT)
commit812f4dcd814b55e182d7cf35b7867254fe63fe40 (patch)
tree65985498766ca85435a373d9cabaf3ba4af5c775 /generic/tclListObj.c
parent810edde822b6b99b1dcc766be690db919e90e361 (diff)
parent23c8c8b5e43fffff7f81e26ffa820d4f51cca5c5 (diff)
downloadtcl-812f4dcd814b55e182d7cf35b7867254fe63fe40.zip
tcl-812f4dcd814b55e182d7cf35b7867254fe63fe40.tar.gz
tcl-812f4dcd814b55e182d7cf35b7867254fe63fe40.tar.bz2
merge trunk
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]);
}
/*