comparison src/evalvars.c @ 23362:f181fe2150ab v8.2.2224

patch 8.2.2224: Vim9: crash if script reloaded with different variable type Commit: https://github.com/vim/vim/commit/07a65d26e7d76ad22d6ef23b50c0faa25e435e02 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 26 20:09:15 2020 +0100 patch 8.2.2224: Vim9: crash if script reloaded with different variable type Problem: Vim9: crash if script reloaded with different variable type. Solution: Check the type when accessing the variable.
author Bram Moolenaar <Bram@vim.org>
date Sat, 26 Dec 2020 20:15:04 +0100
parents d5919c5fd3dc
children 17a0e32eefd4
comparison
equal deleted inserted replaced
23361:5c7e91d7fc6d 23362:f181fe2150ab
782 emsg(_("E985: .= is not supported with script version >= 2")); 782 emsg(_("E985: .= is not supported with script version >= 2"));
783 else if (!ends_excmd2(eap->cmd, arg)) 783 else if (!ends_excmd2(eap->cmd, arg))
784 { 784 {
785 if (vim9script) 785 if (vim9script)
786 { 786 {
787 // Vim9 declaration ":let var: type" 787 // Vim9 declaration ":var name: type"
788 arg = vim9_declare_scriptvar(eap, arg); 788 arg = vim9_declare_scriptvar(eap, arg);
789 } 789 }
790 else 790 else
791 { 791 {
792 // ":let var1 var2" - list values 792 // ":let var1 var2" - list values
3131 3131
3132 if (var_check_permission(di, name) == FAIL) 3132 if (var_check_permission(di, name) == FAIL)
3133 goto failed; 3133 goto failed;
3134 } 3134 }
3135 else 3135 else
3136 {
3136 // can only redefine once 3137 // can only redefine once
3137 di->di_flags &= ~DI_FLAGS_RELOAD; 3138 di->di_flags &= ~DI_FLAGS_RELOAD;
3139
3140 // A Vim9 script-local variable is also present in sn_all_vars and
3141 // sn_var_vals.
3142 if (is_script_local && vim9script)
3143 update_vim9_script_var(FALSE, di, tv, type);
3144 }
3138 3145
3139 // existing variable, need to clear the value 3146 // existing variable, need to clear the value
3140 3147
3141 // Handle setting internal di: variables separately where needed to 3148 // Handle setting internal di: variables separately where needed to
3142 // prevent changing the type. 3149 // prevent changing the type.
3214 di->di_flags |= DI_FLAGS_LOCK; 3221 di->di_flags |= DI_FLAGS_LOCK;
3215 3222
3216 // A Vim9 script-local variable is also added to sn_all_vars and 3223 // A Vim9 script-local variable is also added to sn_all_vars and
3217 // sn_var_vals. 3224 // sn_var_vals.
3218 if (is_script_local && vim9script) 3225 if (is_script_local && vim9script)
3219 add_vim9_script_var(di, tv, type); 3226 update_vim9_script_var(TRUE, di, tv, type);
3220 } 3227 }
3221 3228
3222 if (copy || tv->v_type == VAR_NUMBER || tv->v_type == VAR_FLOAT) 3229 if (copy || tv->v_type == VAR_NUMBER || tv->v_type == VAR_FLOAT)
3223 copy_tv(tv, &di->di_tv); 3230 copy_tv(tv, &di->di_tv);
3224 else 3231 else