diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-06-26 11:17:10 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-06-26 11:17:10 +0100 |
commit | 0fbc9260a75dfc4d86f20e7c0eb76878f513a212 (patch) | |
tree | 1dc8cefcabbabfbb29c641aa4db3c78c243d0ea3 /src/message.c | |
parent | e178af5a586ea023622d460779fdcabbbfac0908 (diff) |
patch 8.2.5161: might still access invalid memoryv8.2.5161
Problem: Might still access invalid memory.
Solution: Add extra check for negative value.
Diffstat (limited to 'src/message.c')
-rw-r--r-- | src/message.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/message.c b/src/message.c index 07566da949..02380e9177 100644 --- a/src/message.c +++ b/src/message.c @@ -949,8 +949,10 @@ msg_may_trunc(int force, char_u *s) 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) |