neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit de72f9098a7287615dc8bbb6293732ac546f51ac
parent ded2925b406f55223f6093544bc3a38534c1e72e
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Sat, 13 Aug 2022 15:44:15 +0800

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

Diffstat:
Msrc/nvim/eval.c | 17+++++++++++++++++
1 file changed, 17 insertions(+), 0 deletions(-)

diff --git 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();