vim-patch:8.2.5161: might still access invalid memory

Problem:    Might still access invalid memory.
Solution:   Add extra check for negative value.

0fbc9260a7

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
Jan Edmund Lazo
2025-12-14 10:41:40 -05:00
parent 7ce17cd2a2
commit f4a33929d9

View File

@@ -1052,8 +1052,11 @@ char *msg_may_trunc(bool force, char *s)
return s;
}
// If something unexpected happened "room" may be negative, check for that
// just in case.
int room = (Rows - cmdline_row - 1) * Columns + sc_col - 1;
if ((force || (shortmess(SHM_TRUNC) && !exmode_active))
if (room > 0
&& (force || (shortmess(SHM_TRUNC) && !exmode_active))
&& (int)strlen(s) - room > 0) {
int size = vim_strsize(s);