Mercurial > vim
changeset 29288:d9acbf59032c v8.2.5161
patch 8.2.5161: might still access invalid memory
Commit: https://github.com/vim/vim/commit/0fbc9260a75dfc4d86f20e7c0eb76878f513a212
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 26 11:17:10 2022 +0100
patch 8.2.5161: might still access invalid memory
Problem: Might still access invalid memory.
Solution: Add extra check for negative value.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 Jun 2022 12:30:04 +0200 |
parents | 8382479d5631 |
children | 430376616aac |
files | src/message.c src/version.c |
diffstat | 2 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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)