aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/userfunc.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2020-05-05 23:38:15 -0400
committerGitHub <noreply@github.com>2020-05-05 23:38:15 -0400
commitf04a9a2c9aa68f98a79b8d7e9917719a8be6049b (patch)
tree4cd229a5856e1dfb1ad42bcf7e9ea3e0fb07f3dd /src/nvim/eval/userfunc.c
parentd2766b06c8fc50d06765c5c607744cc6b5f5ef0a (diff)
parented4df85f6bae488d763b5d0eebbf2db9da25551d (diff)
downloadrneovim-f04a9a2c9aa68f98a79b8d7e9917719a8be6049b.tar.gz
rneovim-f04a9a2c9aa68f98a79b8d7e9917719a8be6049b.tar.bz2
rneovim-f04a9a2c9aa68f98a79b8d7e9917719a8be6049b.zip
Merge #12203 from janlazo/vim-8.2.0648
vim-patch:8.1.{800,868,1581},8.2.{648,649,663,678,681,688,691,692}
Diffstat (limited to 'src/nvim/eval/userfunc.c')
-rw-r--r--src/nvim/eval/userfunc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index c55a29c67c..ae8557a8bc 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -592,6 +592,8 @@ static void cleanup_function_call(funccall_T *fc)
if (!fc_referenced(fc)) {
free_funccal(fc, false);
} else {
+ static int made_copy = 0;
+
// "fc" is still in use. This can happen when returning "a:000",
// assigning "l:" to a global variable or defining a closure.
// Link "fc" in the list for garbage collection later.
@@ -607,6 +609,15 @@ static void cleanup_function_call(funccall_T *fc)
TV_LIST_ITER(&fc->l_varlist, li, {
tv_copy(TV_LIST_ITEM_TV(li), TV_LIST_ITEM_TV(li));
});
+
+ if (++made_copy == 10000) {
+ // We have made a lot of copies. This can happen when
+ // repetitively calling a function that creates a reference to
+ // itself somehow. Call the garbage collector soon to avoid using
+ // too much memory.
+ made_copy = 0;
+ want_garbage_collect = true;
+ }
}
}