Skip to content

Commit fd47265

Browse files
Rhialtochrisbra
authored andcommitted
patch 9.1.0069: ScreenLines may not be correctly initialized, causing hang
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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 59bafc8 commit fd47265

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

src/screen.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,6 +2569,25 @@ screenalloc(int doclear)
25692569
new_LineOffset[new_row] = new_row * Columns;
25702570
new_LineWraps[new_row] = FALSE;
25712571

2572+
(void)vim_memset(new_ScreenLines + new_row * Columns,
2573+
' ', (size_t)Columns * sizeof(schar_T));
2574+
if (enc_utf8)
2575+
{
2576+
(void)vim_memset(new_ScreenLinesUC + new_row * Columns,
2577+
0, (size_t)Columns * sizeof(u8char_T));
2578+
for (int i = 0; i < p_mco; ++i)
2579+
(void)vim_memset(new_ScreenLinesC[i]
2580+
+ new_row * Columns,
2581+
0, (size_t)Columns * sizeof(u8char_T));
2582+
}
2583+
if (enc_dbcs == DBCS_JPNU)
2584+
(void)vim_memset(new_ScreenLines2 + new_row * Columns,
2585+
0, (size_t)Columns * sizeof(schar_T));
2586+
(void)vim_memset(new_ScreenAttrs + new_row * Columns,
2587+
0, (size_t)Columns * sizeof(sattr_T));
2588+
(void)vim_memset(new_ScreenCols + new_row * Columns,
2589+
0, (size_t)Columns * sizeof(colnr_T));
2590+
25722591
/*
25732592
* If the screen is not going to be cleared, copy as much as
25742593
* possible from the old screen to the new one and clear the rest
@@ -2577,24 +2596,6 @@ screenalloc(int doclear)
25772596
*/
25782597
if (!doclear)
25792598
{
2580-
(void)vim_memset(new_ScreenLines + new_row * Columns,
2581-
' ', (size_t)Columns * sizeof(schar_T));
2582-
if (enc_utf8)
2583-
{
2584-
(void)vim_memset(new_ScreenLinesUC + new_row * Columns,
2585-
0, (size_t)Columns * sizeof(u8char_T));
2586-
for (int i = 0; i < p_mco; ++i)
2587-
(void)vim_memset(new_ScreenLinesC[i]
2588-
+ new_row * Columns,
2589-
0, (size_t)Columns * sizeof(u8char_T));
2590-
}
2591-
if (enc_dbcs == DBCS_JPNU)
2592-
(void)vim_memset(new_ScreenLines2 + new_row * Columns,
2593-
0, (size_t)Columns * sizeof(schar_T));
2594-
(void)vim_memset(new_ScreenAttrs + new_row * Columns,
2595-
0, (size_t)Columns * sizeof(sattr_T));
2596-
(void)vim_memset(new_ScreenCols + new_row * Columns,
2597-
0, (size_t)Columns * sizeof(colnr_T));
25982599
old_row = new_row + (screen_Rows - Rows);
25992600
if (old_row >= 0 && ScreenLines != NULL)
26002601
{

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
69,
707709
/**/
708710
68,
709711
/**/

0 commit comments

Comments
 (0)