Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Potential for memory leaks using Tcl_ListObjIndex on abstract lists

Open9d26c038b9f978196513186f9618cffc65c50656Created 40 days agoUpdated 25 days ago
Descriptionplain2026-10-25 02:31:55
As documented in the migration guide, since 9.0, `Tcl_ListObjIndex` may return ephemeral `Tcl_Obj` where the returned object is not owned by the (abstract) list implementation. The caller is supposed to take ownership (call IncrRef/DecrRef directly or by adding it to the interpreter result, another list etc.) or free it with `Tcl_BounceRefCount` to ensure unreferenced objects are freed. Lists created with `lseq` are an example.

Several calls to `Tcl_ListObjIndex` do not doing this, both within core as well as in the included packages like ITcl and TDBC drivers, resulting in potential for memory leaks. This is not currently a major issue as lseq is the only such abstract list in the core and is unlikely to be passed as an argument in the context of the core calls where `Tcl_ListObjIndex` is invoked.

Still, it would be advisable to fix this for the future where abstract lists, whether in the core or in extensions, might become more common.
apnadkarni Ticket [9d26c038b9]: 3 changes [History diff]2026-10-25 03:17:39
dkf Ticket [9d26c038b9]: 3 changes [History diff]2026-11-08 20:38:17
Log in (anonymous is fine) to add a comment.