]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0069: ScreenLines may not be correctly initialized, causing hang v9.1.0069
authorOlaf Seibert <rhialto@falu.nl>
Thu, 1 Feb 2024 20:11:16 +0000 (21:11 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 1 Feb 2024 20:11:16 +0000 (21:11 +0100)
Problem:  ScreenLines may not be correctly initialized, causing hang
          (Olaf Seibert, after 9.0.0220)
Solution: always initialize ScreneLines when allocating a screen
          (Olaf Seibert)

ScreenLines and related structures could be left uninitialized
causing a screen update to run into an infinite loop when using latin1
encoding.

Partly caused because by patch 9.0.0220, which makes mb_ptr2len return
zero for NUL

related: #12671
closes: #13946

Signed-off-by: Olaf Seibert <rhialto@falu.nl>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/screen.c
src/version.c

index 032e447a93aff90c95e3a696c5aa0309f3d4a324..939a3359990942934392a5bf630950c0859e9ff7 100644 (file)
@@ -2569,6 +2569,25 @@ give_up:
            new_LineOffset[new_row] = new_row * Columns;
            new_LineWraps[new_row] = FALSE;
 
+           (void)vim_memset(new_ScreenLines + new_row * Columns,
+                                 ' ', (size_t)Columns * sizeof(schar_T));
+           if (enc_utf8)
+           {
+               (void)vim_memset(new_ScreenLinesUC + new_row * Columns,
+                                  0, (size_t)Columns * sizeof(u8char_T));
+               for (int i = 0; i < p_mco; ++i)
+                   (void)vim_memset(new_ScreenLinesC[i]
+                                                     + new_row * Columns,
+                                  0, (size_t)Columns * sizeof(u8char_T));
+           }
+           if (enc_dbcs == DBCS_JPNU)
+               (void)vim_memset(new_ScreenLines2 + new_row * Columns,
+                                  0, (size_t)Columns * sizeof(schar_T));
+           (void)vim_memset(new_ScreenAttrs + new_row * Columns,
+                                   0, (size_t)Columns * sizeof(sattr_T));
+           (void)vim_memset(new_ScreenCols + new_row * Columns,
+                                   0, (size_t)Columns * sizeof(colnr_T));
+
            /*
             * If the screen is not going to be cleared, copy as much as
             * possible from the old screen to the new one and clear the rest
@@ -2577,24 +2596,6 @@ give_up:
             */
            if (!doclear)
            {
-               (void)vim_memset(new_ScreenLines + new_row * Columns,
-                                     ' ', (size_t)Columns * sizeof(schar_T));
-               if (enc_utf8)
-               {
-                   (void)vim_memset(new_ScreenLinesUC + new_row * Columns,
-                                      0, (size_t)Columns * sizeof(u8char_T));
-                   for (int i = 0; i < p_mco; ++i)
-                       (void)vim_memset(new_ScreenLinesC[i]
-                                                         + new_row * Columns,
-                                      0, (size_t)Columns * sizeof(u8char_T));
-               }
-               if (enc_dbcs == DBCS_JPNU)
-                   (void)vim_memset(new_ScreenLines2 + new_row * Columns,
-                                      0, (size_t)Columns * sizeof(schar_T));
-               (void)vim_memset(new_ScreenAttrs + new_row * Columns,
-                                       0, (size_t)Columns * sizeof(sattr_T));
-               (void)vim_memset(new_ScreenCols + new_row * Columns,
-                                       0, (size_t)Columns * sizeof(colnr_T));
                old_row = new_row + (screen_Rows - Rows);
                if (old_row >= 0 && ScreenLines != NULL)
                {
index ce3c4fde2fa0ddbf591b983f0b0555cad129f8dc..b70c90a26b015a0687a9fd40a7f99bb7f1b97a8e 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    69,
 /**/
     68,
 /**/