0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.2272: Vim9: extend() can violate the type of a variable

Problem:    Vim9: extend() can violate the type of a variable.
Solution:   Add the type to the dictionary or list and check items against it.
            (closes #7593)
This commit is contained in:
Bram Moolenaar
2021-01-02 15:41:03 +01:00
parent 3e0107ea16
commit aa210a3aec
11 changed files with 149 additions and 13 deletions

View File

@@ -2994,6 +2994,24 @@ call_def_function(
}
break;
case ISN_SETTYPE:
{
checktype_T *ct = &iptr->isn_arg.type;
tv = STACK_TV_BOT(-1);
if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
{
free_type(tv->vval.v_dict->dv_type);
tv->vval.v_dict->dv_type = alloc_type(ct->ct_type);
}
else if (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)
{
free_type(tv->vval.v_list->lv_type);
tv->vval.v_list->lv_type = alloc_type(ct->ct_type);
}
}
break;
case ISN_2BOOL:
case ISN_COND2BOOL:
{
@@ -3890,6 +3908,15 @@ ex_disassemble(exarg_T *eap)
iptr->isn_arg.checklen.cl_more_OK ? ">= " : "",
iptr->isn_arg.checklen.cl_min_len);
break;
case ISN_SETTYPE:
{
char *tofree;
smsg("%4d SETTYPE %s", current,
type_name(iptr->isn_arg.type.ct_type, &tofree));
vim_free(tofree);
break;
}
case ISN_COND2BOOL: smsg("%4d COND2BOOL", current); break;
case ISN_2BOOL: if (iptr->isn_arg.number)
smsg("%4d INVERT (!val)", current);