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

@@ -5606,6 +5606,13 @@ void free_operatorfunc_option(void)
}
#endif
/// Mark the global 'operatorfunc' callback with "copyID" so that it is not
/// garbage collected.
bool set_ref_in_opfunc(int copyID)
{
return set_ref_in_callback(&opfunc_cb, copyID, NULL, NULL);
}
/// Handle the "g@" operator: call 'operatorfunc'.
static void op_function(const oparg_T *oap)
FUNC_ATTR_NONNULL_ALL