summaryrefslogtreecommitdiff
path: root/src/vim9execute.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-04-05 17:30:29 +0100
committerBram Moolenaar <Bram@vim.org>2022-04-05 17:30:29 +0100
commit0d1f55c044610f627b1617e4cfbf6e094ff60921 (patch)
tree3fb509eb33b3b2407a260ae7d34582947f9695e7 /src/vim9execute.c
parent478700336d1c72e133b8ff6841e968c1bb1658ed (diff)
downloadvim-git-0d1f55c044610f627b1617e4cfbf6e094ff60921.tar.gz
patch 8.2.4697: Vim9: crash when adding a duplicate key to a dictionaryv8.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)
Diffstat (limited to 'src/vim9execute.c')
-rw-r--r--src/vim9execute.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 6303cc117..99135eadd 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -196,8 +196,10 @@ exe_newdict(int count, ectx_T *ectx)
dict_unref(dict);
return FAIL;
}
- item->di_tv = *STACK_TV_BOT(2 * (idx - count) + 1);
+ 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,7 +5365,7 @@ call_def_function(
did_emsg_def += save_did_emsg_def;
failed_early:
- // Free all local variables, but not arguments.
+ // 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;