vim-patch:8.2.3788: lambda for option that is a function may be freed

Problem:    Lambda for option that is a function may be garbage collected.
Solution:   Set a reference in the funcref. (Yegappan Lakshmanan,
            closes vim/vim#9330)

6ae8fae869

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq
2022-11-07 13:37:22 +08:00
parent 8f9ae52784
commit c00d241981
10 changed files with 977 additions and 763 deletions

View File

@@ -2299,6 +2299,17 @@ int set_thesaurusfunc_option(void)
return retval;
}
/// Mark the global 'completefunc' 'omnifunc' and 'thesaurusfunc' callbacks with
/// "copyID" so that they are not garbage collected.
bool set_ref_in_insexpand_funcs(int copyID)
{
bool abort = set_ref_in_callback(&cfu_cb, copyID, NULL, NULL);
abort = abort || set_ref_in_callback(&ofu_cb, copyID, NULL, NULL);
abort = abort || set_ref_in_callback(&tsrfu_cb, copyID, NULL, NULL);
return abort;
}
/// Get the user-defined completion function name for completion "type"
static char_u *get_complete_funcname(int type)
{