aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-08-21 11:25:27 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-08-21 11:57:04 -0400
commit387c3be82a34f698d483347cbad4a7cfd39153b8 (patch)
treec2396aafffd096a5b341c8d28b4c52c748ec8f03
parent38075200015e0e47d930a0ac7550546fd4cb2f9e (diff)
downloadrneovim-387c3be82a34f698d483347cbad4a7cfd39153b8.tar.gz
rneovim-387c3be82a34f698d483347cbad4a7cfd39153b8.tar.bz2
rneovim-387c3be82a34f698d483347cbad4a7cfd39153b8.zip
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. https://github.com/vim/vim/commit/3679c17917d7ff22e836982c81e5816bd07451dd
-rw-r--r--src/nvim/window.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 8239061a0c..751d70a14a 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -843,8 +843,7 @@ 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
* vertical position. */
- if (oldwin->w_height > 0)
- set_fraction(oldwin);
+ set_fraction(oldwin);
wp->w_fraction = oldwin->w_fraction;
if (flags & WSP_VERT) {
@@ -4791,10 +4790,13 @@ void win_drag_vsep_line(win_T *dragwin, int offset)
#define FRACTION_MULT 16384L
// 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 + wp->w_height / 2)
+ if (wp->w_height > 1) {
+ wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT + wp->w_height / 2)
/ (long)wp->w_height;
+ }
}
/*