aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fold.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-06 11:34:20 +0800
committerGitHub <noreply@github.com>2022-12-06 11:34:20 +0800
commit6d7b94ea086e17d16e2490e56572f17031924af5 (patch)
treeac499496f76fbfafda0d2fece958bda2ccabf852 /src/nvim/fold.c
parent9a6f481ca040c3cb2c39360790f66162e2433435 (diff)
downloadrneovim-6d7b94ea086e17d16e2490e56572f17031924af5.tar.gz
rneovim-6d7b94ea086e17d16e2490e56572f17031924af5.tar.bz2
rneovim-6d7b94ea086e17d16e2490e56572f17031924af5.zip
vim-patch:8.2.4393: possible number overflow with nested folds (#21305)
Problem: Possible number overflow with nested folds. Solution: Avoid a negative line number. https://github.com/vim/vim/commit/6b43471da4516e8f6c17e5dc2eccbb9d0ba2e0a4 Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/fold.c')
-rw-r--r--src/nvim/fold.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 1ff39f3654..08b963ae89 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -1436,15 +1436,13 @@ static void foldMarkAdjustRecurse(win_T *wp, garray_T *gap, linenr_T line1, line
// 5. fold is below line1 and contains line2; need to
// correct nested folds too
if (amount == MAXLNUM) {
- foldMarkAdjustRecurse(wp, &fp->fd_nested, line1 - fp->fd_top,
- line2 - fp->fd_top, amount,
- amount_after + (fp->fd_top - top));
+ foldMarkAdjustRecurse(wp, &fp->fd_nested, 0, line2 - fp->fd_top,
+ amount, amount_after + (fp->fd_top - top));
fp->fd_len -= line2 - fp->fd_top + 1;
fp->fd_top = line1;
} else {
- foldMarkAdjustRecurse(wp, &fp->fd_nested, line1 - fp->fd_top,
- line2 - fp->fd_top, amount,
- amount_after - amount);
+ foldMarkAdjustRecurse(wp, &fp->fd_nested, 0, line2 - fp->fd_top,
+ amount, amount_after - amount);
fp->fd_len += amount_after - amount;
fp->fd_top += amount;
}