0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.1.1575: callbacks may be garbage collected

Problem:    Callbacks may be garbage collected.
Solution:   Set reference in callbacks. (Ozaki Kiichi, closes #4564)
This commit is contained in:
Bram Moolenaar
2019-06-20 03:45:36 +02:00
parent a3fce62c91
commit 75a1a9415b
13 changed files with 164 additions and 7 deletions

View File

@@ -5962,3 +5962,48 @@ wipe_buffer(
if (!aucmd)
unblock_autocmds();
}
#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Mark references in functions of buffers.
*/
int
set_ref_in_buffers(int copyID)
{
int abort = FALSE;
buf_T *bp;
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);
}
}
# 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);
}
# endif
if (abort)
break;
}
return abort;
}
#endif