diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-12-27 14:57:32 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-12-27 14:57:32 (GMT) |
commit | 74ba8ceda7f5765eb6d06f6bac99f565b9a71154 (patch) | |
tree | 30f9805cad842d36d4e5474c555a4248fc2364db /generic | |
parent | d525cce307b002900a04c58a4adff1470f24202c (diff) | |
parent | 20253b8c7d3f3c59314380703be48df859cdf9e6 (diff) | |
download | tcl-74ba8ceda7f5765eb6d06f6bac99f565b9a71154.zip tcl-74ba8ceda7f5765eb6d06f6bac99f565b9a71154.tar.gz tcl-74ba8ceda7f5765eb6d06f6bac99f565b9a71154.tar.bz2 |
[Bug 3598580]: Tcl_ListObjReplace may release deleted elements too early
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclListObj.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 17aa256..1166759 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -857,6 +857,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; @@ -964,14 +968,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]); } /* |