fix: segfault when using string.ustring_tmp()

pull/1295/head
Maciej Sopyło 2019-06-29 16:24:59 +02:00 committed by Alexander Medvednikov
parent 09c447e2b8
commit 58577f57c6
1 changed files with 4 additions and 1 deletions

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