Skip to content

Commit 3571f66

Browse files
pref: fix access in invalid position on v search '' (#13993)
1 parent 473bc02 commit 3571f66

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

vlib/v/pref/pref.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub mut:
110110
test_runner string // can be 'simple' (fastest, but much less detailed), 'tap', 'normal'
111111
profile_file string // the profile results will be stored inside profile_file
112112
profile_no_inline bool // when true, [inline] functions would not be profiled
113-
profile_fns []string // when set, profiling will be off by default, but inside these functions (and what they call) it will be on.
113+
profile_fns []string // when set, profiling will be off by default, but inside these functions (and what they call) it will be on.
114114
translated bool // `v translate doom.v` are we running V code translated from C? allow globals, ++ expressions, etc
115115
is_prod bool // use "-O2"
116116
obfuscate bool // `v -obf program.v`, renames functions to "f_XXX"
@@ -634,7 +634,7 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
634634
eprintln('Use `v $arg` instead.')
635635
exit(1)
636636
}
637-
if arg[0] == `-` {
637+
if arg.len != 0 && arg[0] == `-` {
638638
if arg[1..] in pref.list_of_flags_with_param {
639639
// skip parameter
640640
i++

vlib/v/pref/pref_test.v

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module pref
2+
3+
fn test_check_parametes() {
4+
// reproducing issue https://github.com/vlang/v/issues/13983
5+
_, cmd := parse_args_and_show_errors(['help'], [''], true)
6+
// no command found from args
7+
assert cmd == ''
8+
}

0 commit comments

Comments
 (0)