add boundary check for args parser (#2415)

mine
Jayson Wang 2024-01-03 01:20:18 +08:00 committed by GitHub
parent 6a43167f1a
commit 39d93223d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -30,8 +30,9 @@ func newArgs(p *Interpreter, aa []string) args {
args[contextKey] = a[1:]
case strings.Index(a, fuzzyFlag) == 0:
i++
args[filterKey] = strings.ToLower(strings.TrimSpace(aa[i]))
if i++; i < len(aa) {
args[filterKey] = strings.ToLower(strings.TrimSpace(aa[i]))
}
case strings.Index(a, filterFlag) == 0:
args[filterKey] = strings.ToLower(a[1:])