Artifacts Associated With Ticket 41bc9a
Ticket change [7d77e4c29a] (rid 257545) by serhiy.storchaka on 2026-10-11 06:54:45:
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
<tt>regsub -command</tt> with more than 9 capturing groups can panic: <verbatim> set re {(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)} regsub -command $re abcdefghijkl {apply {args {list [llength $args] $args}}} </verbatim> In 9.0.5 this panics with "unable to alloc 643662021519030588 bytes". In 9.1.1 it happens not to crash, but the last three arguments are empty instead of <tt>j k l</tt>. Valgrind reports uninitialised reads in <tt>Tcl_RegsubObjCmd()</tt> in both. <tt>Tcl_RegsubObjCmd()</tt> always asks the regexp engine for 10 submatches, but with <tt>-command</tt> it passes all <tt>info.nsubs</tt> + 1 of them to the command, reading entries of the match array that were never set, and uses them as string positions and lengths. Asking for all submatches when <tt>-command</tt> is used fixes it; regsub.n also says that each substring matching a capturing sub-RE is appended. - foundin initialized to: "9.0.5, 9.1.0"
- login: "serhiy.storchaka"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "serhiy.storchaka"
- subsystem initialized to: "43. Regexp"
- title initialized to:
regsub -command panics with more than 9 capturing groups
- type initialized to: "Bug"
Ticket change [ab25308c36] (rid 257556) by serhiy.storchaka on 2026-10-11 07:06:58:
- icomment:
Proposed fix in branch [/timeline?r=regsub-command-all-submatches|regsub-command-all-submatches]: with <tt>-command</tt>, ask the regexp engine for all submatches. Tests regexp-32.1 and 32.2.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- icomment: