Skip to content
Tcl Source Code View Ticket
Login

View Ticket

signed integer overflow in TclInitStringRep() macro

Closed / Fixedb6afa337376342ff91953f200db89ff4ff4f5fe6Created 5 years agoUpdated 5 years ago
Descriptionwiki2022-02-19 13:49:20
Example script and corresponding output with UBSan error (-fsanitize=signed-integer-overflow, excludes any previously reported errors):
proc p {} {
set a [string repeat [string repeat a 1023] 1049601]
set a2 [string cat a $a $a]
return [string toupper $a2]
}
set x [p]
tcl/generic/tclExecute.c:5520:6: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
(tclsh eventually exited normally)

Can be prevented with same approach used in [a03e9793d4]; see attached patch.

Referenced by1
jan.nijtmanswiki2022-03-08 15:18:30

Fixed [here]. Thanks!

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