From cd9ca700e5053f8a9666c917310dcc39651e3bfa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 May 2023 22:39:28 +0800 Subject: vim-patch:9.0.0598: using negative array index with negative width window Problem: Using negative array index with negative width window. Solution: Make sure the window width does not become negative. https://github.com/vim/vim/commit/8279af514ca7e5fd3c31cf13b0864163d1a0bfeb Co-authored-by: Bram Moolenaar --- src/nvim/window.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index 45a48f13cc..87e936b92f 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2304,6 +2304,9 @@ static void win_equal_rec(win_T *next_curwin, bool current, frame_T *topfr, int } if (hnc) { // add next_curwin size next_curwin_size -= (int)p_wiw - (m - n); + if (next_curwin_size < 0) { + next_curwin_size = 0; + } new_size += next_curwin_size; room -= new_size - next_curwin_size; } else { @@ -6686,7 +6689,8 @@ static int win_border_width(win_T *wp) /// Set the width of a window. void win_new_width(win_T *wp, int width) { - wp->w_width = width; + // Should we give an error if width < 0? + wp->w_width = width < 0 ? 0 : width; wp->w_pos_changed = true; win_set_inner_size(wp, true); } -- cgit