0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 8.2.2537: Vim9: crash when map() fails

Problem:    Vim9: crash when map() fails.
Solution:   Clear typval before using it. (closes #7884)
This commit is contained in:
Bram Moolenaar
2021-02-21 16:20:18 +01:00
parent dc167465f8
commit 027c4ab4d2
3 changed files with 24 additions and 0 deletions

View File

@@ -2145,6 +2145,7 @@ filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap)
arg_errmsg, TRUE))) arg_errmsg, TRUE)))
break; break;
set_vim_var_string(VV_KEY, di->di_key, -1); set_vim_var_string(VV_KEY, di->di_key, -1);
newtv.v_type = VAR_UNKNOWN;
r = filter_map_one(&di->di_tv, expr, filtermap, r = filter_map_one(&di->di_tv, expr, filtermap,
&newtv, &rem); &newtv, &rem);
clear_tv(get_vim_var_tv(VV_KEY)); clear_tv(get_vim_var_tv(VV_KEY));

View File

@@ -690,6 +690,27 @@ def Test_maparg_mapset()
nunmap <F3> nunmap <F3>
enddef enddef
def Test_map_failure()
CheckFeature job
var lines =<< trim END
vim9script
writefile([], 'Xtmpfile')
silent e Xtmpfile
var d = {[bufnr('%')]: {a: 0}}
au BufReadPost * Func()
def Func()
if d->has_key('')
endif
eval d[expand('<abuf>')]->mapnew((_, v: dict<job>) => 0)
enddef
e
END
CheckScriptFailure(lines, 'E1013:')
au! BufReadPost
delete('Xtmpfile')
enddef
def Test_max() def Test_max()
g:flag = true g:flag = true
var l1: list<number> = g:flag var l1: list<number> = g:flag

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2537,
/**/ /**/
2536, 2536,
/**/ /**/