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

pull/6368/head
Delyan Angelov 2020-09-13 18:08:58 +03:00
parent 8c71ba8912
commit 2bd4355a4c
1 changed files with 3 additions and 0 deletions

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())