aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-11-07 13:37:22 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-11-07 14:25:32 +0800
commitc00d241981f292a6529242bb98ed16cfc8c53ae4 (patch)
treea03acfc293cc5bfc0d78c4d8c6a0b847d37e95d7 /src/nvim/ops.c
parent8f9ae5278464205004c421e49dad640808b2256f (diff)
downloadrneovim-c00d241981f292a6529242bb98ed16cfc8c53ae4.tar.gz
rneovim-c00d241981f292a6529242bb98ed16cfc8c53ae4.tar.bz2
rneovim-c00d241981f292a6529242bb98ed16cfc8c53ae4.zip
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) https://github.com/vim/vim/commit/6ae8fae8696623b527c7fb22567f6a3705b2f0dd Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r--src/nvim/ops.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 2d53918ded..65fc42bc08 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -5606,6 +5606,13 @@ void free_operatorfunc_option(void)
}
#endif
+/// Mark the global 'operatorfunc' callback with "copyID" so that it is not
+/// garbage collected.
+bool set_ref_in_opfunc(int copyID)
+{
+ return set_ref_in_callback(&opfunc_cb, copyID, NULL, NULL);
+}
+
/// Handle the "g@" operator: call 'operatorfunc'.
static void op_function(const oparg_T *oap)
FUNC_ATTR_NONNULL_ALL