]> granicus.if.org Git - vim/commitdiff
patch 8.2.5161: might still access invalid memory v8.2.5161
authorBram Moolenaar <Bram@vim.org>
Sun, 26 Jun 2022 10:17:10 +0000 (11:17 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 26 Jun 2022 10:17:10 +0000 (11:17 +0100)
Problem:    Might still access invalid memory.
Solution:   Add extra check for negative value.

src/message.c
src/version.c

index 07566da9491be10e5604f43e73f95c95173cb370..02380e9177c2e310f429543b9fa9b2a005f30dcd 100644 (file)
@@ -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)
index acf84d1d2d426c4a6d10c56c4f99c03a4a3185e4..9fba35bea067630c7d4e385669c81f49158aa4a5 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5161,
 /**/
     5160,
 /**/