diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-10-15 20:42:20 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-10-15 20:42:20 +0200 |
commit | ed234f24f3a6d697ba9b786d0bc74d4682bfdf47 (patch) | |
tree | 52de9eabe6a57c76ff561d8a7fa5354af6fbb3e0 /src/evalvars.c | |
parent | 74f8eece5e481220e3c0767487c0bb59fa916ed6 (diff) |
patch 8.2.1849: Vim9: garbage collection frees block-local variablesv8.2.1849
Problem: Vim9: garbage collection frees block-local variables.
Solution: Mark all script variables as used.
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index f3253551f2..fd67ad0f5e 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -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; } |