diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-02-21 16:20:18 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-02-21 16:20:18 +0100 |
commit | 027c4ab4d2e3ff031b98e0fb648f5acbea180293 (patch) | |
tree | b0eac633e8d09f20cd8014a26e80dc429b366a5d /src | |
parent | dc167465f87a4f03f9e085597dfcfdde39fcd2b9 (diff) |
patch 8.2.2537: Vim9: crash when map() failsv8.2.2537
Problem: Vim9: crash when map() fails.
Solution: Clear typval before using it. (closes #7884)
Diffstat (limited to 'src')
-rw-r--r-- | src/list.c | 1 | ||||
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 21 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/list.c b/src/list.c index 2af3085cc3..b1080dee0f 100644 --- a/src/list.c +++ b/src/list.c @@ -2145,6 +2145,7 @@ filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap) arg_errmsg, TRUE))) break; set_vim_var_string(VV_KEY, di->di_key, -1); + newtv.v_type = VAR_UNKNOWN; r = filter_map_one(&di->di_tv, expr, filtermap, &newtv, &rem); clear_tv(get_vim_var_tv(VV_KEY)); diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index cb36990657..3ee8a620f6 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -690,6 +690,27 @@ def Test_maparg_mapset() nunmap <F3> 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() g:flag = true var l1: list<number> = g:flag diff --git a/src/version.c b/src/version.c index 3f5ae9d8cc..8d29d52181 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2537, +/**/ 2536, /**/ 2535, |