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

patch 8.2.1849: Vim9: garbage collection frees block-local variables

Problem:    Vim9: garbage collection frees block-local variables.
Solution:   Mark all script variables as used.
This commit is contained in:
Bram Moolenaar
2020-10-15 20:42:20 +02:00
parent 74f8eece5e
commit ed234f24f3
3 changed files with 41 additions and 11 deletions

View File

@@ -303,12 +303,24 @@ garbage_collect_vimvars(int copyID)
int
garbage_collect_scriptvars(int copyID)
{
int i;
int abort = FALSE;
int i;
int idx;
int abort = FALSE;
scriptitem_T *si;
for (i = 1; i <= script_items.ga_len; ++i)
{
abort = abort || set_ref_in_ht(&SCRIPT_VARS(i), copyID, NULL);
si = SCRIPT_ITEM(i);
for (idx = 0; idx < si->sn_var_vals.ga_len; ++idx)
{
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx;
abort = abort || set_ref_in_item(sv->sv_tv, copyID, NULL, NULL);
}
}
return abort;
}