Skip to content
Tcl Source Code History Of Ticket 41bc9a
Login

History Of Ticket 41bc9a

Artifacts Associated With Ticket 41bc9a

  1. Ticket change [7d77e4c29a] (rid 257545) by serhiy.storchaka on 2026-10-11 06:54:45:

    1. cmimetype initialized to: "text/x-fossil-wiki"
    2. 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.
      
    3. foundin initialized to: "9.0.5, 9.1.0"
    4. login: "serhiy.storchaka"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. severity initialized to: "Severe"
    8. status initialized to: "Open"
    9. submitter initialized to: "serhiy.storchaka"
    10. subsystem initialized to: "43. Regexp"
    11. title initialized to:
      regsub -command panics with more than 9 capturing groups
      
    12. type initialized to: "Bug"
  2. Ticket change [ab25308c36] (rid 257556) by serhiy.storchaka on 2026-10-11 07:06:58:

    1. 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.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"