string: fix a one byte leak in .substr()

pull/7605/head
Alexander Medvednikov 2020-12-11 05:12:18 +01:00
parent a297cf8676
commit d319fe14f0
1 changed files with 3 additions and 0 deletions

View File

@ -592,6 +592,9 @@ pub fn (s string) substr(start int, end int) string {
}
}
len := end - start
if len == s.len {
return s.clone()
}
mut res := string{
str: malloc(len + 1)
len: len