patch 8.2.5161: might still access invalid memory
Problem: Might still access invalid memory.
Solution: Add extra check for negative value.
diff --git a/src/message.c b/src/message.c
index 07566da..02380e9 100644
--- a/src/message.c
+++ b/src/message.c
@@ -949,8 +949,10 @@
int n;
int room;
+ // If something unexpected happened "room" may be negative, check for that
+ // just in case.
room = (int)(Rows - cmdline_row - 1) * Columns + sc_col - 1;
- if ((force || (shortmess(SHM_TRUNC) && !exmode_active))
+ if (room > 0 && (force || (shortmess(SHM_TRUNC) && !exmode_active))
&& (n = (int)STRLEN(s) - room) > 0)
{
if (has_mbyte)