Skip to content

Commit 83efbbd

Browse files
authored
fix: error with nil pointer on symlink check (#185)
* fix: error with nil pointer on symlink check * chore: correct the typo on error
1 parent 191933c commit 83efbbd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/scan/scan.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bufio"
2121
"crypto/sha1"
2222
"io"
23+
"io/fs"
2324
"log"
2425
"os"
2526
"path/filepath"
@@ -141,9 +142,10 @@ func contentJobWriter(cfg *cfgReader.EarlybirdConfig, files []File, jobs chan Wo
141142
//Don't do file read/scan on files we know will trigger the filename scan -- Don't open compressed files either
142143
if !isExcludedFileType(cfg, searchFile.Name) && len(CompressPattern.FindStringSubmatch(searchFile.Name)) <= 0 {
143144
fileInfo, err := os.Lstat(searchFile.Path)
144-
if fileInfo.Mode()&os.ModeSymlink != 0 {
145+
if err == nil && fileInfo != nil && fileInfo.Mode()&fs.ModeSymlink != 0 {
145146
continue
146147
}
148+
147149
fileOS, err := os.Open(searchFile.Path) //Open file path
148150
if err != nil {
149151
fileOS, err = os.Open(searchFile.Name) //If file path open fails, try file name

0 commit comments

Comments
 (0)