Overview
| Artifact ID: | 7f92289b8703c72cf509eb9fa400e38d386e6fd9e06a7d1dca09eddc60646bfd |
|---|---|
| Ticket: | 526b01c0b9921b90618f82c398dc2684a60a053a
lset with 2+ indices on an unshared lseq list is a use-after-free (crash) |
| User & Date: | serhiy.storchaka on 2026-10-30 09:12:21 |
Changes
- icomment:
<tt>TclListObjSetElement()</tt> panics only if the list it modifies (<tt>parentList</tt>) is shared, and it is unshared at this point. The element may be shared: <tt>TclListObjSetElement()</tt> takes its own reference, and the code right after the call makes a copy if <tt>subListObj</tt> became shared. The added <tt>Tcl_IncrRefCount()</tt>/<tt>Tcl_DecrRefCount()</tt> only keeps the old element alive while it is stored back, since it may be held only by the cache of the abstract list, which is freed during the call. I cannot reproduce the crash with the current main (1436d27450) or 9.0 (336b75d084), on Linux (also under valgrind) and on Windows 11 (MSVC): <verbatim> % set m [lseq 5] 0 1 2 3 4 % lset m {2 0} X 0 1 X 3 4 </verbatim> What build and platform did you use? - login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"