changeset 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 1578c0ba0dd1
children e865f9c6bb9e
files src/version.c src/window.c
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1331,
+/**/
     1330,
 /**/
     1329,
--- a/src/window.c
+++ b/src/window.c
@@ -1081,8 +1081,7 @@ win_split_ins(
 
     /* Set w_fraction now so that the cursor keeps the same relative
      * vertical position. */
-    if (oldwin->w_height > 0)
-	set_fraction(oldwin);
+    set_fraction(oldwin);
     wp->w_fraction = oldwin->w_fraction;
 
     if (flags & WSP_VERT)
@@ -5682,11 +5681,13 @@ win_drag_vsep_line(win_T *dragwin, int o
 
 /*
  * 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)
 {
-    wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT
+    if (wp->w_height > 1)
+	wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT
 				    + wp->w_height / 2) / (long)wp->w_height;
 }