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/ops.c b/src/ops.c
index a1afc25..f58d6f8 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -3341,13 +3341,29 @@
void
free_operatorfunc_option(void)
{
-# ifdef FEAT_EVAL
+# ifdef FEAT_EVAL
free_callback(&opfunc_cb);
-# endif
+# endif
}
#endif
/*
+ * Mark the global 'operatorfunc' callback with 'copyID' so that it is not
+ * garbage collected.
+ */
+ int
+set_ref_in_opfunc(int copyID UNUSED)
+{
+ int abort = FALSE;
+
+#ifdef FEAT_EVAL
+ abort = set_ref_in_callback(&opfunc_cb, copyID);
+#endif
+
+ return abort;
+}
+
+/*
* Handle the "g@" operator: call 'operatorfunc'.
*/
static void