File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -705,7 +705,7 @@ pub fn executable() string {
705705 // https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew
706706 final_len := C.GetFinalPathNameByHandleW (file, unsafe { & u16 (& final_path[0 ]) },
707707 max_path_buffer_size, 0 )
708- if final_len < u32 (max_path_buffer_size) {
708+ if final_len < u32 (max_path_buffer_size) && final_len != 0 {
709709 sret := unsafe { string_from_wide2 (& u16 (& final_path[0 ]), int (final_len)) }
710710 defer {
711711 unsafe { sret.free () }
@@ -714,7 +714,7 @@ pub fn executable() string {
714714 sret_slice := sret[4 ..]
715715 res := sret_slice.clone ()
716716 return res
717- } else {
717+ } else if final_len != 0 {
718718 eprintln ('os.executable() saw that the executable file path was too long' )
719719 }
720720 }
@@ -862,13 +862,15 @@ pub fn real_path(fpath string) string {
862862 // https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew
863863 final_len := C.GetFinalPathNameByHandleW (file, pu16_ fullpath, max_path_buffer_size,
864864 0 )
865- if final_len < u32 (max_path_buffer_size) {
865+ if final_len < u32 (max_path_buffer_size) && final_len != 0 {
866866 rt := unsafe { string_from_wide2 (pu16_ fullpath, int (final_len)) }
867867 srt := rt[4 ..]
868868 unsafe { res.free () }
869869 res = srt.clone ()
870870 } else {
871- eprintln ('os.real_path() saw that the file path was too long' )
871+ if final_len != 0 {
872+ eprintln ('os.real_path() saw that the file path was too long' )
873+ }
872874 unsafe { res.free () }
873875 return fpath.clone ()
874876 }
You can’t perform that action at this time.
0 commit comments