Added a memory copy to fs.Walk to avoid data races
All checks were successful
/ test (push) Successful in 15s

This commit is contained in:
Eduard Urbach 2025-06-27 11:35:58 +02:00
parent 925fd6ce05
commit ce5416bf91
Signed by: akyoto
GPG key ID: 49226B848C78F6C8

View file

@ -3,6 +3,7 @@
package fs package fs
import ( import (
"strings"
"syscall" "syscall"
"unsafe" "unsafe"
) )
@ -44,16 +45,10 @@ func Walk(directory string, callBack func(string)) error {
continue continue
} }
for i, c := range dirent.Name { bytePointer := (*byte)(unsafe.Pointer(&dirent.Name[0]))
if c != 0 { name := unsafe.String(bytePointer, 256)
continue null := strings.IndexByte(name, 0)
} callBack(strings.Clone(name[:null]))
bytePointer := (*byte)(unsafe.Pointer(&dirent.Name[0]))
name := unsafe.String(bytePointer, i)
callBack(name)
break
}
} }
} }