diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-13 15:44:15 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-08-14 04:29:44 +0800 |
commit | de72f9098a7287615dc8bbb6293732ac546f51ac (patch) | |
tree | 169ce11501959feda99f0b73a4bdedf7e5fdcdf0 | |
parent | ded2925b406f55223f6093544bc3a38534c1e72e (diff) | |
download | rneovim-de72f9098a7287615dc8bbb6293732ac546f51ac.tar.gz rneovim-de72f9098a7287615dc8bbb6293732ac546f51ac.tar.bz2 rneovim-de72f9098a7287615dc8bbb6293732ac546f51ac.zip |
vim-patch:8.2.0061: the execute stack can grow big and never shrinks
Problem: The execute stack can grow big and never shrinks.
Solution: Reduce the size in gargage collect.
https://github.com/vim/vim/commit/3fbcc128cbd2311819cc5a7bb89e45669860f008
-rw-r--r-- | src/nvim/eval.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f0b76b9a10..ff94cf5944 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -4188,6 +4188,23 @@ bool garbage_collect(bool testing) garbage_collect_at_exit = false; } + // The execution stack can grow big, limit the size. + if (exestack.ga_maxlen - exestack.ga_len > 500) { + // Keep 150% of the current size, with a minimum of the growth size. + int n = exestack.ga_len / 2; + if (n < exestack.ga_growsize) { + n = exestack.ga_growsize; + } + + // Don't make it bigger though. + if (exestack.ga_len + n < exestack.ga_maxlen) { + size_t new_len = (size_t)exestack.ga_itemsize * (size_t)(exestack.ga_len + n); + char *pp = xrealloc(exestack.ga_data, new_len); + exestack.ga_maxlen = exestack.ga_len + n; + exestack.ga_data = pp; + } + } + // We advance by two (COPYID_INC) because we add one for items referenced // through previous_funccal. const int copyID = get_copyID(); |