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

do not allow malloc(0)

This commit is contained in:
Alexander Medvednikov
2019-12-16 21:29:32 +03:00
parent 10718557a2
commit e7856a1afc
3 changed files with 14 additions and 3 deletions

View File

@ -1126,6 +1126,9 @@ pub fn (s []string) join_lines() string {
// reverse will return a new reversed string.
pub fn (s string) reverse() string {
if s.len == 0 {
return ''
}
mut res := string {
len: s.len
str: malloc(s.len)