1
0
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:
Nick Treleaven
2021-02-14 18:31:42 +00:00
committed by GitHub
parent d3bcd5d305
commit ea803113c3
36 changed files with 200 additions and 161 deletions

View File

@@ -25,7 +25,7 @@ pub fn read(bytes_needed int) ?[]byte {
}
rbytes := getrandom(batch_size, bstart)
if rbytes == -1 {
free(buffer)
unsafe { free(buffer) }
return read_error
}
bytes_read += rbytes

View File

@@ -15,7 +15,7 @@ const (
// read returns an array of `bytes_needed` random bytes read from the OS.
pub fn read(bytes_needed int) ?[]byte {
mut buffer := malloc(bytes_needed)
mut buffer := unsafe {malloc(bytes_needed)}
// use bcrypt_use_system_preferred_rng because we passed null as algo
status := C.BCryptGenRandom(0, buffer, bytes_needed, bcrypt_use_system_preferred_rng)
if status != status_success {