diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-06-20 03:45:36 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-06-20 03:45:36 +0200 |
commit | 75a1a9415b9c207de5a29b25c0d1949c6c9c5c61 (patch) | |
tree | 470a0887aed4e52e342edbca555e0bec1b85af99 /src/buffer.c | |
parent | a3fce62c911c204ae144b55018f6dc9295088850 (diff) | |
download | vim-git-75a1a9415b9c207de5a29b25c0d1949c6c9c5c61.tar.gz |
patch 8.1.1575: callbacks may be garbage collectedv8.1.1575
Problem: Callbacks may be garbage collected.
Solution: Set reference in callbacks. (Ozaki Kiichi, closes #4564)
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c index c3911ae2b..ee68bc955 100644 --- a/src/buffer.c +++ b/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 |