summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-08-11 15:52:14 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-11 15:52:14 +0100
commitfdc5d17d58cc9c9edc9fb2816e1afaabc531bf1e (patch)
tree65d2a2fe1ad08bc48fa3ee45fa5d2fa3ae1de89b
parentd4cf9fc53e0b1d36e84d28ecd5595a6f102f325e (diff)
downloadvim-git-fdc5d17d58cc9c9edc9fb2816e1afaabc531bf1e.tar.gz
patch 9.0.0192: possible invalid memory access when 'cmdheight' is zerov9.0.0192
Problem: Possible invalid memory access when 'cmdheight' is zero. (Martin Tournoij) Solution: Avoid going over the end of w_lines[] when w_height is Rows. (closes #10882)
-rw-r--r--src/drawscreen.c6
-rw-r--r--src/version.c2
2 files changed, 7 insertions, 1 deletions
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 578c66f2b..a5822b25d 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -1808,9 +1808,13 @@ win_update(win_T *wp)
// Move the entries that were scrolled, disable
// the entries for the lines to be redrawn.
+ // Avoid using a wrong index when 'cmdheight' is
+ // zero and wp->w_height == Rows.
if ((wp->w_lines_valid += j) > wp->w_height)
wp->w_lines_valid = wp->w_height;
- for (idx = wp->w_lines_valid; idx - j >= 0; idx--)
+ for (idx = wp->w_lines_valid >= wp->w_height
+ ? wp->w_height - 1 : wp->w_lines_valid;
+ idx - j >= 0; idx--)
wp->w_lines[idx] = wp->w_lines[idx - j];
while (idx >= 0)
wp->w_lines[idx--].wl_valid = FALSE;
diff --git a/src/version.c b/src/version.c
index c89996625..0369ad200 100644
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 192,
+/**/
191,
/**/
190,