patch 9.1.1048: crash after scrolling and pasting in silent Ex mode
Problem: Crash after scrolling and pasting in silent Ex mode.
(fizz-is-on-the-way)
Solution: Don't move cursor to line 0 when scrolling.
(zeertzjq)
closes: #16506
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/move.c b/src/move.c
index f2780e5..ed252d9 100644
--- a/src/move.c
+++ b/src/move.c
@@ -3285,8 +3285,11 @@
{
// Place cursor at top or bottom of window.
validate_botline();
- curwin->w_cursor.lnum = (dir == FORWARD ? curwin->w_topline
+ linenr_T lnum = (dir == FORWARD ? curwin->w_topline
: curwin->w_botline - 1);
+ // In silent Ex mode the value of w_botline - 1 may be 0,
+ // but cursor lnum needs to be at least 1.
+ curwin->w_cursor.lnum = MAX(lnum, 1);
}
}