diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2021-12-12 16:26:44 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-12 16:26:44 +0000 |
commit | 6ae8fae8696623b527c7fb22567f6a3705b2f0dd (patch) | |
tree | 5013ad6590516571ae06f992906c4270d7f03b45 /src/gui_xim.c | |
parent | 6e371ecb27227ff8fedd8561d0f3880a17576848 (diff) |
patch 8.2.3788: lambda for option that is a function may be freedv8.2.3788
Problem: Lambda for option that is a function may be garbage collected.
Solution: Set a reference in the funcref. (Yegappan Lakshmanan,
closes #9330)
Diffstat (limited to 'src/gui_xim.c')
-rw-r--r-- | src/gui_xim.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/gui_xim.c b/src/gui_xim.c index 6d72ef1d66..4bd1a2eedf 100644 --- a/src/gui_xim.c +++ b/src/gui_xim.c @@ -117,7 +117,7 @@ call_imstatusfunc(void) void free_xim_stuff(void) { -#if defined(FEAT_EVAL) && \ +# if defined(FEAT_EVAL) && \ (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL)) free_callback(&imaf_cb); free_callback(&imsf_cb); @@ -125,6 +125,24 @@ free_xim_stuff(void) } #endif +/* + * Mark the global 'imactivatefunc' and 'imstatusfunc' callbacks with 'copyID' + * so that they are not garbage collected. + */ + int +set_ref_in_im_funcs(int copyID UNUSED) +{ + int abort = FALSE; + +#if defined(FEAT_EVAL) && \ + (defined(FEAT_XIM) || defined(IME_WITHOUT_XIM) || defined(VIMDLL)) + abort = set_ref_in_callback(&imaf_cb, copyID); + abort = abort || set_ref_in_callback(&imsf_cb, copyID); +#endif + + return abort; +} + #if defined(FEAT_XIM) || defined(PROTO) |