From: Bram Moolenaar Date: Sun, 26 Jun 2022 10:17:10 +0000 (+0100) Subject: patch 8.2.5161: might still access invalid memory X-Git-Tag: v8.2.5161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fbc9260a75dfc4d86f20e7c0eb76878f513a212;p=thirdparty%2Fvim.git 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 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) diff --git a/src/version.c b/src/version.c index acf84d1d2d..9fba35bea0 100644 --- a/src/version.c +++ b/src/version.c @@ -735,6 +735,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 5161, /**/ 5160, /**/