summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-12-05 18:13:27 +0100
committerBram Moolenaar <Bram@vim.org>2020-12-05 18:13:27 +0100
commit4029cabbe7c68a304ab8becb495bd6d91c6e97b1 (patch)
treea621844239445997633f5aa6fee32e064bafde8c
parentd0fe620cbbf5f5e00446efa89893036265c5c302 (diff)
downloadvim-git-4029cabbe7c68a304ab8becb495bd6d91c6e97b1.tar.gz
patch 8.2.2095: Vim9: crash when failed dict member is followed by concatv8.2.2095
Problem: Vim9: crash when failed dict member is followed by concatenation. Solution: Remove the dict from the stack. (closes #7416)
-rw-r--r--src/testdir/test_vim9_func.vim19
-rw-r--r--src/version.c2
-rw-r--r--src/vim9execute.c9
3 files changed, 30 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 18aefe08d..18864cfd1 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -1794,6 +1794,25 @@ def Test_abort_even_with_silent()
enddef
sil! Func()
assert_equal('none', g:result)
+ unlet g:result
+ END
+ CheckScriptSuccess(lines)
+enddef
+
+def Test_dict_member_with_silent()
+ var lines =<< trim END
+ vim9script
+ g:result = 'none'
+ var d: dict<any>
+ def Func()
+ try
+ g:result = map([], {_, v -> {}[v]})->join() .. d['']
+ catch
+ endtry
+ enddef
+ silent! Func()
+ assert_equal('0', g:result)
+ unlet g:result
END
CheckScriptSuccess(lines)
enddef
diff --git a/src/version.c b/src/version.c
index a0bf9363c..cfc1639d4 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 */
/**/
+ 2095,
+/**/
2094,
/**/
2093,
diff --git a/src/vim9execute.c b/src/vim9execute.c
index a9fd94e9c..dd36cfa6b 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -2669,6 +2669,15 @@ call_def_function(
{
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_dictkey), key);
+
+ // If :silent! is used we will continue, make sure the
+ // stack contents makes sense.
+ clear_tv(tv);
+ --ectx.ec_stack.ga_len;
+ tv = STACK_TV_BOT(-1);
+ clear_tv(tv);
+ tv->v_type = VAR_NUMBER;
+ tv->vval.v_number = 0;
goto on_fatal_error;
}
clear_tv(tv);