[windows] Fix leak in glob.

This commit is contained in:
Jeroen van Rijn
2022-03-29 16:13:17 +02:00
parent 085fa199ea
commit df32b5b46c
7 changed files with 23 additions and 16 deletions
+1
View File
@@ -82,6 +82,7 @@ read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []F
wpath_search[len(wpath)+2] = 0
path := cleanpath_from_buf(wpath)
defer delete(path)
find_data := &win32.WIN32_FIND_DATAW{}
find_handle := win32.FindFirstFileW(raw_data(wpath_search), find_data)
-1
View File
@@ -2,7 +2,6 @@ package os
import "core:time"
File_Info :: struct {
fullpath: string,
name: string,
+6 -6
View File
@@ -80,7 +80,7 @@ stat :: proc(name: string, allocator := context.allocator) -> (File_Info, Errno)
return _stat(name, attrs, allocator)
}
fstat :: proc(fd: Handle, allocator := context.allocator) -> (File_Info, Errno) {
fstat :: proc(fd: Handle, allocator := context.allocator) -> (fi: File_Info, errno: Errno) {
if fd == 0 {
return {}, ERROR_INVALID_HANDLE
}
@@ -94,14 +94,14 @@ fstat :: proc(fd: Handle, allocator := context.allocator) -> (File_Info, Errno)
h := win32.HANDLE(fd)
switch win32.GetFileType(h) {
case win32.FILE_TYPE_PIPE, win32.FILE_TYPE_CHAR:
fi: File_Info
fi.fullpath = path
fi.name = basename(path)
fi.mode |= file_type_mode(h)
return fi, ERROR_NONE
errno = ERROR_NONE
case:
fi, errno = file_info_from_get_file_information_by_handle(path, h)
}
return file_info_from_get_file_information_by_handle(path, h)
fi.fullpath = path
return
}