commit f4a33929d9cd890e993771937935febe6bb88c92
parent 7ce17cd2a2657f0dd58213dc45d0309b18913a6f
Author: Jan Edmund Lazo <jan.lazo@mail.utoronto.ca>
Date: Sun, 14 Dec 2025 10:41:40 -0500
vim-patch:8.2.5161: might still access invalid memory
Problem: Might still access invalid memory.
Solution: Add extra check for negative value.
https://github.com/vim/vim/commit/0fbc9260a75dfc4d86f20e7c0eb76878f513a212
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/nvim/message.c b/src/nvim/message.c
@@ -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);