in Tcl_ListObjReplace, the deleted elements are Tcl_DecrRefCount'ed BEFORE new elements are Tcl_IncrRefCount'ed. Isn't that a problem if the inserted element happens to be in the list (and only in the list). It would be freed, and the freed memory would be added back to the list. It wouold have to be from custom code (for example, moves an element to the end). Not from script or Tcl_Eval where the objects are ref'ed on the stack and hence will not be released after the Tcl_DecrRefCount.