summaryrefslogtreecommitdiff
path: root/src/ops.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-12-12 16:26:44 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-12 16:26:44 +0000
commit6ae8fae8696623b527c7fb22567f6a3705b2f0dd (patch)
tree5013ad6590516571ae06f992906c4270d7f03b45 /src/ops.c
parent6e371ecb27227ff8fedd8561d0f3880a17576848 (diff)
downloadvim-git-6ae8fae8696623b527c7fb22567f6a3705b2f0dd.tar.gz
patch 8.2.3788: lambda for option that is a function may be freedv8.2.3788
Problem: Lambda for option that is a function may be garbage collected. Solution: Set a reference in the funcref. (Yegappan Lakshmanan, closes #9330)
Diffstat (limited to 'src/ops.c')
-rw-r--r--src/ops.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/ops.c b/src/ops.c
index a1afc258e..f58d6f8d1 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -3341,13 +3341,29 @@ set_operatorfunc_option(void)
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