vim-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 vim/vim#1509)  Make option test check all number options with
            empty value.
a12e40351d
This commit is contained in:
Jan Edmund Lazo 2018-09-23 00:52:13 -04:00
parent fe191d95a2
commit bcc174e6df
2 changed files with 14 additions and 1 deletions

View File

@ -1434,7 +1434,7 @@ do_set (
|| (long *)varp == &p_wcm)
&& (*arg == '<'
|| *arg == '^'
|| ((!arg[1] || ascii_iswhite(arg[1]))
|| (*arg != NUL && (!arg[1] || ascii_iswhite(arg[1]))
&& !ascii_isdigit(*arg)))) {
value = string_to_key(arg);
if (value == 0 && (long *)varp != &p_wcm) {

View File

@ -29,6 +29,19 @@ function! Test_isfname()
set isfname&
endfunction
function Test_wildchar()
" Empty 'wildchar' used to access invalid memory.
call assert_fails('set wildchar=', 'E521:')
call assert_fails('set wildchar=abc', 'E521:')
set wildchar=<Esc>
let a=execute('set wildchar?')
call assert_equal("\n wildchar=<Esc>", a)
set wildchar=27
let a=execute('set wildchar?')
call assert_equal("\n wildchar=<Esc>", a)
set wildchar&
endfunction
function! Test_options()
let caught = 'ok'
try