From a297cf86763e9793f40f21dd79f52486c6a972cc Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 11 Dec 2020 05:03:25 +0100 Subject: [PATCH] string: fix one byte leak in clone() --- vlib/builtin/string.v | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index eb95f38f0d..47a3aa532e 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -180,6 +180,10 @@ fn (a string) clone_static() string { } pub fn (a string) clone() string { + if a == '' { + // TODO perf? an extra check in each clone() is not nice + return '' + } mut b := string{ str: unsafe {malloc(a.len + 1)} len: a.len