Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 57b53101339ce8d618ad3d4eebf4475d2ba3aad3aa0dd6d6bbbb40ba92d80ae8
Ticket: 28de50dcee4f6888eaed987bf1d795ac67138b5f
Crash on invalid Unicode code points
User & Date: apnadkarni on 2026-11-25 14:28:35
Changes

  1. closedate changed to: "2461370.1031872109"
  2. closer changed to: "apnadkarni"
  3. icomment:
    > What could be done additionally is add a check to ExtendStringRepWithUnicode, line 4674, like:
    
    That does not fix the actual problem in that TclUtfCount returns the wrong value.
    
    > The flag TCL_COMBINE is useful if you want to build a UTF-16 decoder using Tcl_UniCharToUtf()
    
    I don't get it. Tcl_UniCharToUtf takes a 32-bit Unichar and outputs UTF-8. Where does UTF-16 come in? Surrogate code points absolutely should not be treated as surrogates in UTF-32 sequences. I really do not like these modifications to the Unicode standard behavior. Different parts of Tcl make differing assumptions which makes it difficult to reason about correct behavior. There *might* have been a need in 8.x. There certainly is not one in Tcl 9 if this is the only use for the flag. I'm going to push for this to be eliminated, particularly as the flag is passed as part of the data, which is unwarranted.
    
    Yes, I understand scripts cannot generate invalid encodings. But as I said, we should try and protect against bad data coming in through the C API's as well.
    
    Thanks for merging to 9.0 but it only created a fork for me :-) It takes me a while to cherrypick because I repeat the test and valgrind cycle for merges to every branch. (8.6 I more or less ignore).
    
  4. login: "apnadkarni"
  5. mimetype: "text/x-markdown"