From d319fe14f04d7406dfb6bf930cb8c8a17012d6b2 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 11 Dec 2020 05:12:18 +0100 Subject: [PATCH] string: fix a one byte leak in .substr() --- vlib/builtin/string.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index 47a3aa532e..1d17535e3e 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -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