1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fix: segfault when using string.ustring_tmp()

This commit is contained in:
Maciej Sopyło 2019-06-29 16:24:59 +02:00 committed by Alexander Medvednikov
parent 09c447e2b8
commit 58577f57c6

View File

@ -653,6 +653,9 @@ pub fn (s string) ustring() ustring {
// right away. Uses global buffer for storing runes []int array.
__global g_ustring_runes []int
pub fn (s string) ustring_tmp() ustring {
if g_ustring_runes.len == 0 {
g_ustring_runes = new_array(0, 128, sizeof(int))
}
mut res := ustring {
s: s
}
@ -811,7 +814,7 @@ pub fn (s string) reverse() string {
}
for i := s.len - 1; i >= 0; i-- {
res[s.len-i-1] = s[i]
res[s.len-i-1] = s[i]
}
return res