Deep copy path when registering file handle

This commit is contained in:
Matéo Duparc 2021-12-20 12:38:05 +01:00
parent d6e75be376
commit b232bb7826
Signed by: hardcoresushi
GPG Key ID: 007F84120107191E
1 changed files with 4 additions and 4 deletions

View File

@ -37,7 +37,7 @@ func mangleOpenFlags(flags uint32) (newFlags int) {
return newFlags return newFlags
} }
func (volume *Volume) registerFileHandle(file File) int { func (volume *Volume) registerFileHandle(fd int, cName, path string) int {
handleID := -1 handleID := -1
c := 0 c := 0
for handleID == -1 { for handleID == -1 {
@ -47,7 +47,7 @@ func (volume *Volume) registerFileHandle(file File) int {
} }
c++ c++
} }
volume.file_handles[handleID] = file volume.file_handles[handleID] = File{os.NewFile(uintptr(fd), cName), string([]byte(path[:]))}//pathCopy.String()}
return handleID return handleID
} }
@ -381,7 +381,7 @@ func gcf_open_read_mode(sessionID int, path string) int {
if err != nil { if err != nil {
return -1 return -1
} }
return volume.registerFileHandle(File{os.NewFile(uintptr(fd), cName), path}) return volume.registerFileHandle(fd, cName, path)
} }
//export gcf_open_write_mode //export gcf_open_write_mode
@ -414,7 +414,7 @@ func gcf_open_write_mode(sessionID int, path string, mode uint32) int {
if err != nil { if err != nil {
return -1 return -1
} }
return volume.registerFileHandle(File{os.NewFile(uintptr(fd), cName), path}) return volume.registerFileHandle(fd, cName, path)
} }
//export gcf_truncate //export gcf_truncate