Skip to content

Commit 4029cab

Browse files
committed
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Problem: Vim9: crash when failed dict member is followed by concatenation. Solution: Remove the dict from the stack. (closes #7416)
1 parent d0fe620 commit 4029cab

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/testdir/test_vim9_func.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,25 @@ def Test_abort_even_with_silent()
17941794
enddef
17951795
sil! Func()
17961796
assert_equal('none', g:result)
1797+
unlet g:result
1798+
END
1799+
CheckScriptSuccess(lines)
1800+
enddef
1801+
1802+
def Test_dict_member_with_silent()
1803+
var lines =<< trim END
1804+
vim9script
1805+
g:result = 'none'
1806+
var d: dict<any>
1807+
def Func()
1808+
try
1809+
g:result = map([], {_, v -> {}[v]})->join() .. d['']
1810+
catch
1811+
endtry
1812+
enddef
1813+
silent! Func()
1814+
assert_equal('0', g:result)
1815+
unlet g:result
17971816
END
17981817
CheckScriptSuccess(lines)
17991818
enddef

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2095,
753755
/**/
754756
2094,
755757
/**/

src/vim9execute.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,6 +2669,15 @@ call_def_function(
26692669
{
26702670
SOURCING_LNUM = iptr->isn_lnum;
26712671
semsg(_(e_dictkey), key);
2672+
2673+
// If :silent! is used we will continue, make sure the
2674+
// stack contents makes sense.
2675+
clear_tv(tv);
2676+
--ectx.ec_stack.ga_len;
2677+
tv = STACK_TV_BOT(-1);
2678+
clear_tv(tv);
2679+
tv->v_type = VAR_NUMBER;
2680+
tv->vval.v_number = 0;
26722681
goto on_fatal_error;
26732682
}
26742683
clear_tv(tv);

0 commit comments

Comments
 (0)