vim-patch:8.1.0475: memory not freed on exit when quit in autocmd

Problem:    Memory not freed on exit when quit in autocmd.
Solution:   Remember funccal stack when executing autocmd.
27e80c885b
This commit is contained in:
erw7
2019-08-31 15:09:30 +09:00
parent f04a9a2c9a
commit 17f067f4b4
6 changed files with 63 additions and 37 deletions

View File

@@ -871,17 +871,19 @@ char_u *eval_to_string(char_u *arg, char_u **nextcmd, int convert)
char_u *eval_to_string_safe(char_u *arg, char_u **nextcmd, int use_sandbox)
{
char_u *retval;
void *save_funccalp;
funccal_entry_T funccal_entry;
save_funccalp = save_funccal();
if (use_sandbox)
++sandbox;
++textlock;
retval = eval_to_string(arg, nextcmd, FALSE);
if (use_sandbox)
--sandbox;
--textlock;
restore_funccal(save_funccalp);
save_funccal(&funccal_entry);
if (use_sandbox) {
sandbox++;
}
textlock++;
retval = eval_to_string(arg, nextcmd, false);
if (use_sandbox) {
sandbox--;
}
textlock--;
restore_funccal();
return retval;
}
@@ -9747,9 +9749,11 @@ const void *var_shada_iter(const void *const iter, const char **const name,
void var_set_global(const char *const name, typval_T vartv)
{
funccall_T *const saved_funccal = (funccall_T *)save_funccal();
funccal_entry_T funccall_entry;
save_funccal(&funccall_entry);
set_var(name, strlen(name), &vartv, false);
restore_funccal(saved_funccal);
restore_funccal();
}
int store_session_globals(FILE *fd)
@@ -10305,8 +10309,10 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments)
.autocmd_fname = autocmd_fname,
.autocmd_match = autocmd_match,
.autocmd_bufnr = autocmd_bufnr,
.funccalp = save_funccal()
.funccalp = (void *)get_current_funccal()
};
funccal_entry_T funccal_entry;
save_funccal(&funccal_entry);
provider_call_nesting++;
typval_T argvars[3] = {
@@ -10333,7 +10339,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments)
tv_list_unref(arguments);
// Restore caller scope information
restore_funccal(provider_caller_scope.funccalp);
restore_funccal();
provider_caller_scope = saved_provider_caller_scope;
provider_call_nesting--;
assert(provider_call_nesting >= 0);