Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 3a32de9be6f32f3fd2816fd0056c68fec712acac0a53eb7ef2ae073d658396bd
Ticket: 94c6511e870541dd5c4fbf8af014a07868b30f37
Undefined pointer arithmetic in `INST_LREPLACE` when compiled `linsert`, `lreplace` or `ledit` insert two or more elements
User & Date: bef on 2026-11-06 18:59:05
Changes

  1. icomment:
    Fix on branch [bug-94c651-lreplace-pointer-overflow](/info/bug-94c651-lreplace-pointer-overflow).
    
    The fix makes `numNewElems` a `Tcl_Size`, like the other stack counts in that function. Then `numNewElems - 1` is at least -1, and the offset stays small and signed. Test `lreplace-5.3` covers `lreplace` on a shared and an unshared list, as well as `linsert` and `ledit`. It checks the result, but it only fails under UBSan with the pointer-overflow check. On the branch, `lreplace.test`, `lsearch.test`, `linsert.test`, `compile.test`, `execute.test` and `clock.test` pass under ASan and UBSan with no report.
    
  2. login: "bef"
  3. mimetype: "text/x-markdown"