Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f305bc01ecadf8edc789a75b9b6e1e8389bf2a67224d4afd0a37242eb6942c87
Ticket: 28de50dcee4f6888eaed987bf1d795ac67138b5f
Crash on invalid Unicode code points
User & Date: jan.nijtmans on 2026-11-25 14:17:44
Changes

  1. assignee changed to: "apnadkarni"
  2. closedate changed to: "2461370.0956584606"
  3. closer changed to: "jan.nijtmans"
  4. icomment:
    Thanks for fixing this!  I agree with this solution, and merged it to core-9-0-branch and core-8-6-branch too.
    
    >...  TCL_COMBINE ... As far as I can tell, there is no need in Tcl 9 for this flag
    
    The flag TCL_COMBINE is useful if you want to build a UTF-16 decoder using Tcl_UniCharToUtf().  The alternative is a new Tcl_Char16ToUtf(), which shares a lot of code with Tcl_UniCharToUtf(). It didn't seem worth it at the time.
    
    Note that this cannot be triggered at pure script-level, only when feeding Tcl_NewUnicodeObj() with invalid UTF-32 data.
    
    What could be done additionally is add a check to ExtendStringRepWithUnicode, line 4674, like:
    <pre>
    dst += Tcl_UniCharToUtf(((unsigned)unicode[i] < 0x110000) ? unicode[i] : 0xFFFD, dst);
    </pre>
    
    That would also have prevented this crash.
    
  5. login: "jan.nijtmans"
  6. mimetype: "text/x-fossil-wiki"
  7. resolution changed to: "Fixed"
  8. status changed to: "Closed"