1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fix int.str() memory bug

This commit is contained in:
Alexander Medvednikov 2019-12-09 16:41:07 +03:00
parent f68d9d1a16
commit 75280bb54c

View File

@ -19,7 +19,7 @@ pub fn (nn int) str() string {
return '0'
}
max := 16
mut buf := calloc(max)
mut buf := calloc(max+1)
mut len := 0
mut is_neg := false
if n < 0 {
@ -38,6 +38,7 @@ pub fn (nn int) str() string {
buf[max - len - 1] = `-`
len++
}
buf[max] = `\0`
return tos(buf + max - len, len)
}