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 #9330)
diff --git a/src/quickfix.c b/src/quickfix.c
index c7abc8e..eeee806 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -7675,7 +7675,8 @@
}
/*
- * 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 int
mark_quickfix_ctx(qf_info_T *qi, int copyID)
@@ -7683,13 +7684,17 @@
int i;
int abort = FALSE;
typval_T *ctx;
+ callback_T *cb;
for (i = 0; i < LISTCOUNT && !abort; ++i)
{
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);
+
+ cb = &qi->qf_lists[i].qftf_cb;
+ abort = abort || set_ref_in_callback(cb, copyID);
}
return abort;
@@ -7710,6 +7715,10 @@
if (abort)
return abort;
+ abort = set_ref_in_callback(&qftf_cb, copyID);
+ if (abort)
+ return abort;
+
FOR_ALL_TAB_WINDOWS(tp, win)
{
if (win->w_llist != NULL)