0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.1127: Vim9: getting a dict member may not work

Problem:    Vim9: getting a dict member may not work.
Solution:   Clear the dict only after copying the item. (closes #6390)
This commit is contained in:
Bram Moolenaar
2020-07-04 19:19:43 +02:00
parent eeb27bfe28
commit fb9d5c51c8
3 changed files with 10 additions and 1 deletions

View File

@@ -2188,6 +2188,7 @@ call_def_function(
{
dict_T *dict;
dictitem_T *di;
typval_T temp_tv;
tv = STACK_TV_BOT(-1);
if (tv->v_type != VAR_DICT || tv->vval.v_dict == NULL)
@@ -2203,8 +2204,11 @@ call_def_function(
semsg(_(e_dictkey), iptr->isn_arg.string);
goto failed;
}
clear_tv(tv);
// Clear the dict after getting the item, to avoid that it
// make the item invalid.
temp_tv = *tv;
copy_tv(&di->di_tv, tv);
clear_tv(&temp_tv);
}
break;