Skip to content

Commit 81101d4

Browse files
authored
builtin: fix int.str_l() integer overflow (#25458)
1 parent 9eef7ec commit 81101d4

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎vlib/builtin/int.v‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ fn (nn int) str_l(max int) string {
7474
return '0'
7575
}
7676

77+
// overflow protect
78+
$if new_int ? && x64 {
79+
if n == min_i64 {
80+
return '-9223372036854775808'
81+
}
82+
} $else {
83+
if n == min_i32 {
84+
return '-2147483648'
85+
}
86+
}
87+
7788
mut is_neg := false
7889
if n < 0 {
7990
n = -n

0 commit comments

Comments
 (0)