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

os: add check for path.len == 0 in vfopen

This commit is contained in:
Delyan Angelov 2020-09-13 18:08:58 +03:00
parent 8c71ba8912
commit 2bd4355a4c

View File

@ -191,6 +191,9 @@ pub fn mv_by_cp(source string, target string) ? {
// NB: os.vfopen is useful for compatibility with C libraries, that expect `FILE *`.
// If you write pure V code, os.create or os.open are more convenient.
pub fn vfopen(path, mode string) ?&C.FILE {
if path.len == 0 {
return error('vfopen called with ""')
}
mut fp := voidptr(0)
$if windows {
fp = C._wfopen(path.to_wide(), mode.to_wide())