mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
string: fix one byte leak in clone()
This commit is contained in:
parent
18ec24dd53
commit
a297cf8676
@ -180,6 +180,10 @@ fn (a string) clone_static() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn (a string) clone() string {
|
pub fn (a string) clone() string {
|
||||||
|
if a == '' {
|
||||||
|
// TODO perf? an extra check in each clone() is not nice
|
||||||
|
return ''
|
||||||
|
}
|
||||||
mut b := string{
|
mut b := string{
|
||||||
str: unsafe {malloc(a.len + 1)}
|
str: unsafe {malloc(a.len + 1)}
|
||||||
len: a.len
|
len: a.len
|
||||||
|
Loading…
Reference in New Issue
Block a user