vim-patch:8.2.3788: lambda for option that is a function may be freed

Problem:    Lambda for option that is a function may be garbage collected.
Solution:   Set a reference in the funcref. (Yegappan Lakshmanan,
            closes vim/vim#9330)

6ae8fae869

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq
2022-11-07 13:37:22 +08:00
parent 8f9ae52784
commit c00d241981
10 changed files with 977 additions and 763 deletions

View File

@@ -6686,7 +6686,8 @@ int set_errorlist(win_T *wp, list_T *list, int action, char *title, dict_T *what
return retval;
}
/// Mark the context as in use for all the lists in a quickfix stack.
/// Mark the quickfix context and callback function as in use for all the lists
/// in a quickfix stack.
static bool mark_quickfix_ctx(qf_info_T *qi, int copyID)
{
bool abort = false;
@@ -6695,8 +6696,11 @@ static bool mark_quickfix_ctx(qf_info_T *qi, int copyID)
typval_T *ctx = qi->qf_lists[i].qf_ctx;
if (ctx != NULL && ctx->v_type != VAR_NUMBER
&& ctx->v_type != VAR_STRING && ctx->v_type != VAR_FLOAT) {
abort = set_ref_in_item(ctx, copyID, NULL, NULL);
abort = abort || set_ref_in_item(ctx, copyID, NULL, NULL);
}
Callback *cb = &qi->qf_lists[i].qf_qftf_cb;
abort = abort || set_ref_in_callback(cb, copyID, NULL, NULL);
}
return abort;
@@ -6711,6 +6715,11 @@ bool set_ref_in_quickfix(int copyID)
return abort;
}
abort = set_ref_in_callback(&qftf_cb, copyID, NULL, NULL);
if (abort) {
return abort;
}
FOR_ALL_TAB_WINDOWS(tp, win) {
if (win->w_llist != NULL) {
abort = mark_quickfix_ctx(win->w_llist, copyID);