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:
parent
f68d9d1a16
commit
75280bb54c
@ -19,7 +19,7 @@ pub fn (nn int) str() string {
|
|||||||
return '0'
|
return '0'
|
||||||
}
|
}
|
||||||
max := 16
|
max := 16
|
||||||
mut buf := calloc(max)
|
mut buf := calloc(max+1)
|
||||||
mut len := 0
|
mut len := 0
|
||||||
mut is_neg := false
|
mut is_neg := false
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
@ -38,6 +38,7 @@ pub fn (nn int) str() string {
|
|||||||
buf[max - len - 1] = `-`
|
buf[max - len - 1] = `-`
|
||||||
len++
|
len++
|
||||||
}
|
}
|
||||||
|
buf[max] = `\0`
|
||||||
return tos(buf + max - len, len)
|
return tos(buf + max - len, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user