Skip to content

Commit a12e403

Browse files
committed
patch 8.0.0370: invalid memory access when setting wildchar empty
Problem: Invalid memory access when setting wildchar empty. Solution: Avoid going over the end of the option value. (Dominique Pelle, closes #1509) Make option test check all number options with empty value.
1 parent c43a8b8 commit a12e403

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/gen_opt_test.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ let test_values = {
4646
\ 'updatecount': [[0, 1, 8, 9999], [-1]],
4747
\ 'updatetime': [[0, 1, 8, 9999], [-1]],
4848
\ 'verbose': [[-1, 0, 1, 8, 9999], []],
49+
\ 'wildcharm': [[-1, 0, 100], []],
4950
\ 'winheight': [[1, 10, 999], [-1, 0]],
5051
\ 'winminheight': [[0, 1], [-1]],
5152
\ 'winminwidth': [[0, 1, 10], [-1]],
@@ -137,7 +138,7 @@ let test_values = {
137138
\ 'rubydll': [[], []],
138139
\ 'tcldll': [[], []],
139140
\
140-
\ 'othernum': [[-1, 0, 100], []],
141+
\ 'othernum': [[-1, 0, 100], ['']],
141142
\ 'otherstring': [['', 'xxx'], []],
142143
\}
143144

src/option.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4612,7 +4612,7 @@ do_set(
46124612
|| (long *)varp == &p_wcm)
46134613
&& (*arg == '<'
46144614
|| *arg == '^'
4615-
|| ((!arg[1] || vim_iswhite(arg[1]))
4615+
|| (*arg != NUL && (!arg[1] || vim_iswhite(arg[1]))
46164616
&& !VIM_ISDIGIT(*arg))))
46174617
{
46184618
value = string_to_key(arg);
@@ -5843,7 +5843,7 @@ set_string_option(
58435843
opt_flags)) == NULL)
58445844
did_set_option(opt_idx, opt_flags, TRUE);
58455845

5846-
/* call autocomamnd after handling side effects */
5846+
/* call autocommand after handling side effects */
58475847
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
58485848
if (saved_oldval != NULL)
58495849
{

src/testdir/test_options.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ function! Test_isfname()
2929
set isfname&
3030
endfunction
3131

32+
function Test_wildchar()
33+
" Empty 'wildchar' used to access invalid memory.
34+
call assert_fails('set wildchar=', 'E521:')
35+
call assert_fails('set wildchar=abc', 'E521:')
36+
set wildchar=<Esc>
37+
let a=execute('set wildchar?')
38+
call assert_equal("\n wildchar=<Esc>", a)
39+
set wildchar=27
40+
let a=execute('set wildchar?')
41+
call assert_equal("\n wildchar=<Esc>", a)
42+
set wildchar&
43+
endfunction
44+
3245
function Test_options()
3346
let caught = 'ok'
3447
try

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
370,
767769
/**/
768770
369,
769771
/**/

0 commit comments

Comments
 (0)