mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check unsafe V function calls (#8752)
This commit is contained in:
@@ -21,8 +21,10 @@ pub fn decode(data string) string {
|
||||
if size <= 0 {
|
||||
return ''
|
||||
}
|
||||
buffer := malloc(size)
|
||||
return tos(buffer, decode_in_buffer(data, buffer))
|
||||
unsafe {
|
||||
buffer := malloc(size)
|
||||
return tos(buffer, decode_in_buffer(data, buffer))
|
||||
}
|
||||
}
|
||||
|
||||
// encode encodes the `string` value passed in `data` to base64.
|
||||
@@ -34,8 +36,10 @@ pub fn encode(data string) string {
|
||||
if size <= 0 {
|
||||
return ''
|
||||
}
|
||||
buffer := malloc(size)
|
||||
return tos(buffer, encode_in_buffer(data, buffer))
|
||||
unsafe {
|
||||
buffer := malloc(size)
|
||||
return tos(buffer, encode_in_buffer(data, buffer))
|
||||
}
|
||||
}
|
||||
|
||||
// decode_url returns a decoded URL `string` version of
|
||||
|
||||
@@ -165,7 +165,7 @@ fn utf8util_char_len(b byte) int {
|
||||
// up_low make the dirt job
|
||||
fn up_low(s string, upper_flag bool) string {
|
||||
mut index := 0
|
||||
mut str_res := malloc(s.len + 1)
|
||||
mut str_res := unsafe {malloc(s.len + 1)}
|
||||
|
||||
for {
|
||||
ch_len := utf8util_char_len(s[index])
|
||||
@@ -289,11 +289,9 @@ fn up_low(s string, upper_flag bool) string {
|
||||
// for c compatibility set the ending 0
|
||||
unsafe {
|
||||
str_res[index] = 0
|
||||
//C.printf("str_res: %s\n--------------\n",str_res)
|
||||
return tos(str_res, s.len)
|
||||
}
|
||||
|
||||
//C.printf("str_res: %s\n--------------\n",str_res)
|
||||
|
||||
return tos(str_res, s.len)
|
||||
}
|
||||
|
||||
// find_char_in_table utility function for up_low, search utf8 chars in the conversion table
|
||||
|
||||
Reference in New Issue
Block a user