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/eval.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/eval.c')
-rw-r--r-- | src/eval.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index e2aa41b34f..64381f0f3d 100644 --- a/src/eval.c +++ b/src/eval.c @@ -4516,6 +4516,18 @@ garbage_collect(int testing) // callbacks in buffers abort = abort || set_ref_in_buffers(copyID); + // 'completefunc', 'omnifunc' and 'thesaurusfunc' callbacks + abort = abort || set_ref_in_insexpand_funcs(copyID); + + // 'operatorfunc' callback + abort = abort || set_ref_in_opfunc(copyID); + + // 'tagfunc' callback + abort = abort || set_ref_in_tagfunc(copyID); + + // 'imactivatefunc' and 'imstatusfunc' callbacks + abort = abort || set_ref_in_im_funcs(copyID); + #ifdef FEAT_LUA abort = abort || set_ref_in_lua(copyID); #endif @@ -4744,6 +4756,22 @@ set_ref_in_list_items(list_T *l, int copyID, ht_stack_T **ht_stack) } /* + * Mark the partial in callback 'cb' with "copyID". + */ + int +set_ref_in_callback(callback_T *cb, int copyID) +{ + typval_T tv; + + if (cb->cb_name == NULL || *cb->cb_name == NUL || cb->cb_partial == NULL) + return FALSE; + + tv.v_type = VAR_PARTIAL; + tv.vval.v_partial = cb->cb_partial; + return set_ref_in_item(&tv, copyID, NULL, NULL); +} + +/* * Mark all lists and dicts referenced through typval "tv" with "copyID". * "list_stack" is used to add lists to be marked. Can be NULL. * "ht_stack" is used to add hashtabs to be marked. Can be NULL. |