From 55dbf5c3798cde8f9bfd36cd17dce636f6f6ea08 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Nov 2023 10:44:19 +0800 Subject: fix(messages): validate msg_grid before using msg_grid_pos (#26189) --- src/nvim/message.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index 2ff0172ac4..2ba6355528 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2990,10 +2990,13 @@ void msg_clr_eos_force(void) int msg_startcol = (cmdmsg_rl) ? 0 : msg_col; int msg_endcol = (cmdmsg_rl) ? Columns - msg_col : Columns; + // TODO(bfredl): ugly, this state should already been validated at this + // point. But msg_clr_eos() is called in a lot of places. if (msg_grid.chars && msg_row < msg_grid_pos) { - // TODO(bfredl): ugly, this state should already been validated at this - // point. But msg_clr_eos() is called in a lot of places. - msg_row = msg_grid_pos; + msg_grid_validate(); + if (msg_row < msg_grid_pos) { + msg_row = msg_grid_pos; + } } grid_fill(&msg_grid_adj, msg_row, msg_row + 1, msg_startcol, msg_endcol, -- cgit