diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-02 15:41:03 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-02 15:41:03 +0100 |
commit | aa210a3aeccc33c6051978017959126b037f94af (patch) | |
tree | 29c2f91c51dc55a52e427f89643ae4b9c4c56c58 /src/vim9script.c | |
parent | 3e0107ea16349b354e0e9712e95b09ef019e99e5 (diff) | |
download | vim-git-aa210a3aeccc33c6051978017959126b037f94af.tar.gz |
patch 8.2.2272: Vim9: extend() can violate the type of a variablev8.2.2272
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)
Diffstat (limited to 'src/vim9script.c')
-rw-r--r-- | src/vim9script.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/vim9script.c b/src/vim9script.c index 269300c5a..b7c0f67d1 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -661,10 +661,10 @@ vim9_declare_scriptvar(exarg_T *eap, char_u *arg) * with a hashtable) and sn_var_vals (lookup by index). * When "create" is TRUE this is a new variable, otherwise find and update an * existing variable. - * When "type" is NULL use "tv" for the type. + * When "*type" is NULL use "tv" for the type and update "*type". */ void -update_vim9_script_var(int create, dictitem_T *di, typval_T *tv, type_T *type) +update_vim9_script_var(int create, dictitem_T *di, typval_T *tv, type_T **type) { scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); hashitem_T *hi; @@ -715,10 +715,9 @@ update_vim9_script_var(int create, dictitem_T *di, typval_T *tv, type_T *type) } if (sv != NULL) { - if (type == NULL) - sv->sv_type = typval2type(tv, &si->sn_type_list); - else - sv->sv_type = type; + if (*type == NULL) + *type = typval2type(tv, &si->sn_type_list); + sv->sv_type = *type; } // let ex_export() know the export worked. |