1
0
forked from aniani/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.
This commit is contained in:
Bram Moolenaar
2022-09-26 23:08:22 +01:00
parent 3bdef10dc1
commit 8279af514c
3 changed files with 28 additions and 1 deletions

View File

@@ -2089,6 +2089,8 @@ win_equal_rec(
if (hnc) // add next_curwin size
{
next_curwin_size -= p_wiw - (m - n);
if (next_curwin_size < 0)
next_curwin_size = 0;
new_size += next_curwin_size;
room -= new_size - next_curwin_size;
}
@@ -6611,7 +6613,8 @@ scroll_to_fraction(win_T *wp, int prev_height)
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_lines_valid = 0;
changed_line_abv_curs_win(wp);
// Handled in win_fix_scroll()