Patch 8.2.4697
Problem: Vim9: crash when adding a duplicate key to a dictionary.
Solution: Clear the stack item when it has been moved into the dictionary.
(closes #10087)
Files: src/vim9execute.c, src/testdir/test_vim9_expr.vim
*** ../vim-8.2.4696/src/vim9execute.c 2022-04-03 21:52:47.770067812 +0100
--- src/vim9execute.c 2022-04-05 17:15:12.351416548 +0100
***************
*** 196,203 ****
dict_unref(dict);
return FAIL;
}
! item->di_tv = *STACK_TV_BOT(2 * (idx - count) + 1);
item->di_tv.v_lock = 0;
if (dict_add(dict, item) == FAIL)
{
// can this ever happen?
--- 196,205 ----
dict_unref(dict);
return FAIL;
}
! tv = STACK_TV_BOT(2 * (idx - count) + 1);
! item->di_tv = *tv;
item->di_tv.v_lock = 0;
+ tv->v_type = VAR_UNKNOWN;
if (dict_add(dict, item) == FAIL)
{
// can this ever happen?
***************
*** 5363,5369 ****
did_emsg_def += save_did_emsg_def;
failed_early:
! // Free all local variables, but not arguments.
for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx)
clear_tv(STACK_TV(idx));
ex_nesting_level = orig_nesting_level;
--- 5365,5371 ----
did_emsg_def += save_did_emsg_def;
failed_early:
! // Free all arguments and local variables.
for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx)
clear_tv(STACK_TV(idx));
ex_nesting_level = orig_nesting_level;
*** ../vim-8.2.4696/src/testdir/test_vim9_expr.vim 2022-03-31
20:02:52.422045605 +0100
--- src/testdir/test_vim9_expr.vim 2022-04-05 17:20:31.662881095 +0100
***************
*** 2774,2779 ****
--- 2774,2782 ----
v9.CheckScriptFailure(['vim9script', "var x = {xxx: 1,"], 'E723:', 2)
v9.CheckDefAndScriptFailure(["var x = {['a']: xxx}"], ['E1001:', 'E121:'],
1)
v9.CheckDefAndScriptFailure(["var x = {a: 1, a: 2}"], 'E721:', 1)
+ g:key = 'x'
+ v9.CheckDefExecAndScriptFailure(["var x = {[g:key]: 'text', [g:key]:
'text'}"], 'E721:', 1)
+ unlet g:key
v9.CheckDefExecAndScriptFailure(["var x = g:anint.member"], ['E715:',
'E488:'], 1)
v9.CheckDefExecAndScriptFailure(["var x = g:dict_empty.member"], 'E716:', 1)
*** ../vim-8.2.4696/src/version.c 2022-04-05 15:30:56.312425624 +0100
--- src/version.c 2022-04-05 17:13:19.251608664 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4697,
/**/
--
What do you get when you cross a joke with a rehtorical question?
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220405163128.8C95D1C0561%40moolenaar.net.