Skip to content

Commit

Permalink
Fix nil pointer access
Browse files Browse the repository at this point in the history
Fix this issue: 
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x5b3310]

goroutine 1 [running]:
github.com/99designs/keyring.(*fileKeyring).resolveDir(0x7fa61e988400?)
        /Users/pfautre/Library/Go/pkg/mod/github.com/99designs/[email protected]/file.go:48 +0x90
github.com/99designs/keyring.(*fileKeyring).Keys(0xc000280020?)
        /Users/pfautre/Library/Go/pkg/mod/github.com/99designs/[email protected]/file.go:169 +0x2b
main.main()
```
  • Loading branch information
Scapal authored Oct 24, 2022
1 parent 81fed19 commit 590d15a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion file.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (k *fileKeyring) resolveDir() (string, error) {
stat, err := os.Stat(dir)
if os.IsNotExist(err) {
err = os.MkdirAll(dir, 0700)
} else if err != nil && !stat.IsDir() {
} else if err != nil && stat !=nil && !stat.IsDir() {
err = fmt.Errorf("%s is a file, not a directory", dir)
}

Expand Down

0 comments on commit 590d15a

Please sign in to comment.