mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -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:
45
src/buffer.c
45
src/buffer.c
@@ -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
|
||||
|
Reference in New Issue
Block a user