diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2013-01-03 14:07:24 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2013-01-03 14:07:24 (GMT) |
commit | 48d8cf61b7fd0af160956618fdf9e4cbccebf078 (patch) | |
tree | 54dad526f36acf29f43fabc0987a1a640026950d /generic/tclListObj.c | |
parent | c164d719c23ebe8d20d8420dc2345163a36878eb (diff) | |
parent | 6470859885f92e276993f88322b090eca3cb24f2 (diff) | |
download | tcl-48d8cf61b7fd0af160956618fdf9e4cbccebf078.zip tcl-48d8cf61b7fd0af160956618fdf9e4cbccebf078.tar.gz tcl-48d8cf61b7fd0af160956618fdf9e4cbccebf078.tar.bz2 |
merge main dev branch
Diffstat (limited to 'generic/tclListObj.c')
-rw-r--r-- | generic/tclListObj.c | 17 |
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]); } /* |