diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-04-19 07:52:53 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-04-19 08:09:46 +0800 |
commit | 8e0ad6e261b81e9e2649bdba103904867b7ff6ef (patch) | |
tree | 2fc4e753fb8caf6176792267fb099205ca18f1a8 /src | |
parent | 0a3645a72307afa563683a6e06c544810e0b65eb (diff) | |
download | rneovim-8e0ad6e261b81e9e2649bdba103904867b7ff6ef.tar.gz rneovim-8e0ad6e261b81e9e2649bdba103904867b7ff6ef.tar.bz2 rneovim-8e0ad6e261b81e9e2649bdba103904867b7ff6ef.zip |
vim-patch:9.0.1462: recursively calling :defer function if it does :qa
Problem: Recursively calling :defer function if it does :qa.
Solution: Clear the defer entry before calling the function. (closes vim/vim#12266)
https://github.com/vim/vim/commit/42994bf678f46dc9ca66e49f512261da8864fff6
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval/userfunc.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 63d5f94f11..e8b50d8c94 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -3242,12 +3242,24 @@ static void handle_defer_one(funccall_T *funccal) { for (int idx = funccal->fc_defer.ga_len - 1; idx >= 0; idx--) { defer_T *dr = ((defer_T *)funccal->fc_defer.ga_data) + idx; + + if (dr->dr_name == NULL) { + // already being called, can happen if function does ":qa" + continue; + } + funcexe_T funcexe = { .fe_evaluate = true }; + typval_T rettv; rettv.v_type = VAR_UNKNOWN; // tv_clear() uses this - call_func(dr->dr_name, -1, &rettv, dr->dr_argcount, dr->dr_argvars, &funcexe); + + char *name = dr->dr_name; + dr->dr_name = NULL; + + call_func(name, -1, &rettv, dr->dr_argcount, dr->dr_argvars, &funcexe); + tv_clear(&rettv); - xfree(dr->dr_name); + xfree(name); for (int i = dr->dr_argcount - 1; i >= 0; i--) { tv_clear(&dr->dr_argvars[i]); } |