summaryrefslogtreecommitdiffstats
path: root/src/evalbuffer.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-12-12 16:26:44 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-12 16:26:44 +0000
commit6ae8fae8696623b527c7fb22567f6a3705b2f0dd (patch)
tree5013ad6590516571ae06f992906c4270d7f03b45 /src/evalbuffer.c
parent6e371ecb27227ff8fedd8561d0f3880a17576848 (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/evalbuffer.c')
-rw-r--r--src/evalbuffer.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/evalbuffer.c b/src/evalbuffer.c
index 77acf8fe90..ba16436ded 100644
--- a/src/evalbuffer.c
+++ b/src/evalbuffer.c
@@ -26,31 +26,25 @@ set_ref_in_buffers(int copyID)
FOR_ALL_BUFFERS(bp)
{
listener_T *lnr;
- typval_T tv;
for (lnr = bp->b_listener; !abort && lnr != NULL; lnr = lnr->lr_next)
- {
- if (lnr->lr_callback.cb_partial != NULL)
- {
- tv.v_type = VAR_PARTIAL;
- tv.vval.v_partial = lnr->lr_callback.cb_partial;
- abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
- }
- }
+ abort = abort || set_ref_in_callback(&lnr->lr_callback, copyID);
# ifdef FEAT_JOB_CHANNEL
- if (!abort && bp->b_prompt_callback.cb_partial != NULL)
- {
- tv.v_type = VAR_PARTIAL;
- tv.vval.v_partial = bp->b_prompt_callback.cb_partial;
- abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
- }
- if (!abort && bp->b_prompt_interrupt.cb_partial != NULL)
- {
- tv.v_type = VAR_PARTIAL;
- tv.vval.v_partial = bp->b_prompt_interrupt.cb_partial;
- abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
- }
+ if (!abort)
+ abort = abort || set_ref_in_callback(&bp->b_prompt_callback, copyID);
+ if (!abort)
+ abort = abort || set_ref_in_callback(&bp->b_prompt_interrupt, copyID);
# endif
+#ifdef FEAT_COMPL_FUNC
+ if (!abort)
+ abort = abort || set_ref_in_callback(&bp->b_cfu_cb, copyID);
+ if (!abort)
+ abort = abort || set_ref_in_callback(&bp->b_ofu_cb, copyID);
+ if (!abort)
+ abort = abort || set_ref_in_callback(&bp->b_tsrfu_cb, copyID);
+#endif
+ if (!abort)
+ abort = abort || set_ref_in_callback(&bp->b_tfu_cb, copyID);
if (abort)
break;
}