1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

pref: fix access in invalid position on v search '' (#13993)

This commit is contained in:
Vincenzo Palazzo 2022-04-10 09:21:58 +02:00 committed by GitHub
parent 473bc0254d
commit 3571f66a82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -634,7 +634,7 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
eprintln('Use `v $arg` instead.')
exit(1)
}
if arg[0] == `-` {
if arg.len != 0 && arg[0] == `-` {
if arg[1..] in pref.list_of_flags_with_param {
// skip parameter
i++

8
vlib/v/pref/pref_test.v Normal file
View File

@ -0,0 +1,8 @@
module pref
fn test_check_parametes() {
// reproducing issue https://github.com/vlang/v/issues/13983
_, cmd := parse_args_and_show_errors(['help'], [''], true)
// no command found from args
assert cmd == ''
}