Overview
| Artifact ID: | dad15f254281a7f0c932a10f2fda587e69ceb4f5a76f02c81e6e814006c3fea6 |
|---|---|
| Ticket: | 3595762fffffffffffffffffffffffffffffffff
Extra Tcl_DecrRefCount in Tcl_LSearchjObjCmd |
| User & Date: | serhiy.storchaka on 2026-10-11 11:20:44 |
Changes
- icomment:
This is reachable: matching fails with "out of memory" when the dissector's per-character work array cannot be allocated, e.g. for a quantified group with a backref on a long string. The extra <code>Tcl_DecrRefCount(patObj)</code> then frees the pattern while it is still in use. Reproducer: run <code>(ulimit -v 1100000; tclsh lsearch-uaf.tcl)</code> with <verbatim> proc t {} { set l [list [string repeat a 100000000]] set pat [string cat {^(?:(a)\1)*} {$}] for {set i 0} {$i < 4} {incr i} { catch {lsearch -regexp $l $pat} msg puts "$msg: $pat" } } t </verbatim> On 9.0.5 the last line prints <code>invokeStk1</code> instead of the pattern. Proposed fix in branch [/timeline?r=lsearch-regexp-error-refcount|lsearch-regexp-error-refcount]. - login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"