Skip to content

Commit d4d0d43

Browse files
committed
dirent: handle nil DirEntry in StatDirEntry
1 parent ca81468 commit d4d0d43

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

dirent.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"sync"
77
"sync/atomic"
8+
"syscall"
89
"unsafe"
910
)
1011

@@ -36,6 +37,9 @@ func loadFileInfo(pinfo **fileInfo) *fileInfo {
3637
// If fs.DirEntry de is a fastwalk.DirEntry it's Stat() method is used and the
3738
// returned fs.FileInfo may be a previously cached result.
3839
func StatDirEntry(path string, de fs.DirEntry) (fs.FileInfo, error) {
40+
if de == nil {
41+
return nil, &os.PathError{Op: "stat", Path: path, Err: syscall.EINVAL}
42+
}
3943
if de.Type()&os.ModeSymlink == 0 {
4044
return de.Info()
4145
}

0 commit comments

Comments
 (0)