comparison src/window.c @ 12910:d21adefd4a50 v8.0.1331

patch 8.0.1331: possible crash when window can be zero lines high commit https://github.com/vim/vim/commit/3679c17917d7ff22e836982c81e5816bd07451dd Author: Bram Moolenaar <Bram@vim.org> Date: Wed Nov 22 22:22:11 2017 +0100 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.
author Christian Brabandt <cb@256bit.org>
date Wed, 22 Nov 2017 22:30:06 +0100
parents 351cf7c67bbe
children af2e0401eb8c
comparison
equal deleted inserted replaced
12909:1578c0ba0dd1 12910:d21adefd4a50
1079 else 1079 else
1080 frame_append(curfrp, frp); 1080 frame_append(curfrp, frp);
1081 1081
1082 /* Set w_fraction now so that the cursor keeps the same relative 1082 /* Set w_fraction now so that the cursor keeps the same relative
1083 * vertical position. */ 1083 * vertical position. */
1084 if (oldwin->w_height > 0) 1084 set_fraction(oldwin);
1085 set_fraction(oldwin);
1086 wp->w_fraction = oldwin->w_fraction; 1085 wp->w_fraction = oldwin->w_fraction;
1087 1086
1088 if (flags & WSP_VERT) 1087 if (flags & WSP_VERT)
1089 { 1088 {
1090 wp->w_p_scr = curwin->w_p_scr; 1089 wp->w_p_scr = curwin->w_p_scr;
5680 5679
5681 #define FRACTION_MULT 16384L 5680 #define FRACTION_MULT 16384L
5682 5681
5683 /* 5682 /*
5684 * Set wp->w_fraction for the current w_wrow and w_height. 5683 * Set wp->w_fraction for the current w_wrow and w_height.
5684 * Has no effect when the window is less than two lines.
5685 */ 5685 */
5686 void 5686 void
5687 set_fraction(win_T *wp) 5687 set_fraction(win_T *wp)
5688 { 5688 {
5689 wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT 5689 if (wp->w_height > 1)
5690 wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT
5690 + wp->w_height / 2) / (long)wp->w_height; 5691 + wp->w_height / 2) / (long)wp->w_height;
5691 } 5692 }
5692 5693
5693 /* 5694 /*
5694 * Set the height of a window. 5695 * Set the height of a window.