Fixed for loop requesting out-of-range index in pickFile()

This commit is contained in:
Seednode 2022-10-29 10:41:03 -05:00
parent f6924ba7b5
commit 3450ea89e0
2 changed files with 6 additions and 4 deletions

View File

@ -496,12 +496,12 @@ func pickFile(args []string, filters *Filters, sort string, fileCache *[]string)
}
}
fileCount := len(fileList) - 1
fileCount := len(fileList)
r := rand.Intn(fileCount)
r := rand.Intn(fileCount - 1)
for i := 0; i < fileCount; i++ {
if r > fileCount {
if r >= (fileCount - 1) {
r = 0
} else {
r++
@ -518,6 +518,8 @@ func pickFile(args []string, filters *Filters, sort string, fileCache *[]string)
if isImage {
return filePath, nil
}
continue
}
return filePath, nil

View File

@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra"
)
var Version = "0.20.8"
var Version = "0.20.9"
func init() {
rootCmd.AddCommand(versionCmd)