vim-patch:8.0.1331: possible crash when window can be zero lines high

Problem:    Possible crash when window can be zero lines high. (Joseph
            Dornisch)
Solution:   Only set w_fraction if the window is at least two lines high.
3679c17917
This commit is contained in:
Jan Edmund Lazo 2018-08-21 11:25:27 -04:00
parent 3807520001
commit 387c3be82a

View File

@ -843,7 +843,6 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
/* Set w_fraction now so that the cursor keeps the same relative /* Set w_fraction now so that the cursor keeps the same relative
* vertical position. */ * vertical position. */
if (oldwin->w_height > 0)
set_fraction(oldwin); set_fraction(oldwin);
wp->w_fraction = oldwin->w_fraction; wp->w_fraction = oldwin->w_fraction;
@ -4791,11 +4790,14 @@ void win_drag_vsep_line(win_T *dragwin, int offset)
#define FRACTION_MULT 16384L #define FRACTION_MULT 16384L
// Set wp->w_fraction for the current w_wrow and w_height. // Set wp->w_fraction for the current w_wrow and w_height.
// Has no effect when the window is less than two lines.
void set_fraction(win_T *wp) void set_fraction(win_T *wp)
{ {
if (wp->w_height > 1) {
wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT + wp->w_height / 2) wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT + wp->w_height / 2)
/ (long)wp->w_height; / (long)wp->w_height;
} }
}
/* /*
* Set the height of a window. * Set the height of a window.