Skip to content

Commit

Permalink
patch 9.0.0192: possible invalid memory access when 'cmdheight' is zero
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
brammool committed Aug 11, 2022
1 parent d4cf9fc commit fdc5d17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/drawscreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
192,
/**/
191,
/**/
Expand Down

0 comments on commit fdc5d17

Please sign in to comment.