diff --git a/vlib/builtin/int.v b/vlib/builtin/int.v index 30a3aa50cc..c01b543e11 100644 --- a/vlib/builtin/int.v +++ b/vlib/builtin/int.v @@ -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) }