Skip to content
Tcl Source Code View Ticket
Login

View Ticket

UpdateStringOfDict(): signed integer overflow

Closed / Fixed74cc95b563dd5450eac9e0ea9c8ad1e4273c9d41Created 4 years agoUpdated 4 years ago
Descriptionwiki2022-10-04 06:31:42
…which these example scripts trigger and the attached patch prevents:
  • # s has string representation with length INT_MAX-1
    set s [string repeat [string repeat {a} 14949] 143654]
    set d1 [dict create aa $s]
    puts [string is upper $d1]
    
    tcl/generic/tclDictObj.c:539:14: runtime error: signed integer overflow: 2 + 2147483646 cannot be represented in type 'int'
    max size for a Tcl value (2147483647 bytes) exceeded
    
    (tclsh aborts)
  • # s has string representation with length INT_MAX-1
    set s [string repeat [string repeat {a} 14949] 143654]
    set d2 [dict create a $s z {}]
    puts [string is upper $d2]
    
    tcl/generic/tclDictObj.c:531:14: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
    max size for a Tcl value (2147483647 bytes) exceeded
    
    (tclsh aborts)
Referenced by1
jan.nijtmanswiki2022-10-06 10:24:16

Should be fixed [here]

Log in (anonymous is fine) to add a comment.

Attachments: