0
0
mirror of https://github.com/vim/vim.git synced 2025-10-08 06:04:08 -04:00

patch 7.4.797

Problem:    Crash when using more lines for the command line than
            'maxcombine'.
Solution:   Use the correct array index.  Also, do not try redrawing when
            exiting.  And use screen_Columns instead of Columns.
This commit is contained in:
Bram Moolenaar
2015-07-25 22:53:00 +02:00
parent 33c3a694fc
commit 5f95f288a2
2 changed files with 32 additions and 29 deletions

View File

@@ -279,6 +279,7 @@ redraw_asap(type)
int type; int type;
{ {
int rows; int rows;
int cols = screen_Columns;
int r; int r;
int ret = 0; int ret = 0;
schar_T *screenline; /* copy from ScreenLines[] */ schar_T *screenline; /* copy from ScreenLines[] */
@@ -291,28 +292,28 @@ redraw_asap(type)
#endif #endif
redraw_later(type); redraw_later(type);
if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY)) if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY) || exiting)
return ret; return ret;
/* Allocate space to save the text displayed in the command line area. */ /* Allocate space to save the text displayed in the command line area. */
rows = Rows - cmdline_row; rows = screen_Rows - cmdline_row;
screenline = (schar_T *)lalloc( screenline = (schar_T *)lalloc(
(long_u)(rows * Columns * sizeof(schar_T)), FALSE); (long_u)(rows * cols * sizeof(schar_T)), FALSE);
screenattr = (sattr_T *)lalloc( screenattr = (sattr_T *)lalloc(
(long_u)(rows * Columns * sizeof(sattr_T)), FALSE); (long_u)(rows * cols * sizeof(sattr_T)), FALSE);
if (screenline == NULL || screenattr == NULL) if (screenline == NULL || screenattr == NULL)
ret = 2; ret = 2;
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
{ {
screenlineUC = (u8char_T *)lalloc( screenlineUC = (u8char_T *)lalloc(
(long_u)(rows * Columns * sizeof(u8char_T)), FALSE); (long_u)(rows * cols * sizeof(u8char_T)), FALSE);
if (screenlineUC == NULL) if (screenlineUC == NULL)
ret = 2; ret = 2;
for (i = 0; i < p_mco; ++i) for (i = 0; i < p_mco; ++i)
{ {
screenlineC[i] = (u8char_T *)lalloc( screenlineC[i] = (u8char_T *)lalloc(
(long_u)(rows * Columns * sizeof(u8char_T)), FALSE); (long_u)(rows * cols * sizeof(u8char_T)), FALSE);
if (screenlineC[i] == NULL) if (screenlineC[i] == NULL)
ret = 2; ret = 2;
} }
@@ -320,7 +321,7 @@ redraw_asap(type)
if (enc_dbcs == DBCS_JPNU) if (enc_dbcs == DBCS_JPNU)
{ {
screenline2 = (schar_T *)lalloc( screenline2 = (schar_T *)lalloc(
(long_u)(rows * Columns * sizeof(schar_T)), FALSE); (long_u)(rows * cols * sizeof(schar_T)), FALSE);
if (screenline2 == NULL) if (screenline2 == NULL)
ret = 2; ret = 2;
} }
@@ -331,27 +332,27 @@ redraw_asap(type)
/* Save the text displayed in the command line area. */ /* Save the text displayed in the command line area. */
for (r = 0; r < rows; ++r) for (r = 0; r < rows; ++r)
{ {
mch_memmove(screenline + r * Columns, mch_memmove(screenline + r * cols,
ScreenLines + LineOffset[cmdline_row + r], ScreenLines + LineOffset[cmdline_row + r],
(size_t)Columns * sizeof(schar_T)); (size_t)cols * sizeof(schar_T));
mch_memmove(screenattr + r * Columns, mch_memmove(screenattr + r * cols,
ScreenAttrs + LineOffset[cmdline_row + r], ScreenAttrs + LineOffset[cmdline_row + r],
(size_t)Columns * sizeof(sattr_T)); (size_t)cols * sizeof(sattr_T));
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
{ {
mch_memmove(screenlineUC + r * Columns, mch_memmove(screenlineUC + r * cols,
ScreenLinesUC + LineOffset[cmdline_row + r], ScreenLinesUC + LineOffset[cmdline_row + r],
(size_t)Columns * sizeof(u8char_T)); (size_t)cols * sizeof(u8char_T));
for (i = 0; i < p_mco; ++i) for (i = 0; i < p_mco; ++i)
mch_memmove(screenlineC[i] + r * Columns, mch_memmove(screenlineC[i] + r * cols,
ScreenLinesC[r] + LineOffset[cmdline_row + r], ScreenLinesC[i] + LineOffset[cmdline_row + r],
(size_t)Columns * sizeof(u8char_T)); (size_t)cols * sizeof(u8char_T));
} }
if (enc_dbcs == DBCS_JPNU) if (enc_dbcs == DBCS_JPNU)
mch_memmove(screenline2 + r * Columns, mch_memmove(screenline2 + r * cols,
ScreenLines2 + LineOffset[cmdline_row + r], ScreenLines2 + LineOffset[cmdline_row + r],
(size_t)Columns * sizeof(schar_T)); (size_t)cols * sizeof(schar_T));
#endif #endif
} }
@@ -366,28 +367,28 @@ redraw_asap(type)
for (r = 0; r < rows; ++r) for (r = 0; r < rows; ++r)
{ {
mch_memmove(current_ScreenLine, mch_memmove(current_ScreenLine,
screenline + r * Columns, screenline + r * cols,
(size_t)Columns * sizeof(schar_T)); (size_t)cols * sizeof(schar_T));
mch_memmove(ScreenAttrs + off, mch_memmove(ScreenAttrs + off,
screenattr + r * Columns, screenattr + r * cols,
(size_t)Columns * sizeof(sattr_T)); (size_t)cols * sizeof(sattr_T));
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
if (enc_utf8) if (enc_utf8)
{ {
mch_memmove(ScreenLinesUC + off, mch_memmove(ScreenLinesUC + off,
screenlineUC + r * Columns, screenlineUC + r * cols,
(size_t)Columns * sizeof(u8char_T)); (size_t)cols * sizeof(u8char_T));
for (i = 0; i < p_mco; ++i) for (i = 0; i < p_mco; ++i)
mch_memmove(ScreenLinesC[i] + off, mch_memmove(ScreenLinesC[i] + off,
screenlineC[i] + r * Columns, screenlineC[i] + r * cols,
(size_t)Columns * sizeof(u8char_T)); (size_t)cols * sizeof(u8char_T));
} }
if (enc_dbcs == DBCS_JPNU) if (enc_dbcs == DBCS_JPNU)
mch_memmove(ScreenLines2 + off, mch_memmove(ScreenLines2 + off,
screenline2 + r * Columns, screenline2 + r * cols,
(size_t)Columns * sizeof(schar_T)); (size_t)cols * sizeof(schar_T));
#endif #endif
SCREEN_LINE(cmdline_row + r, 0, Columns, Columns, FALSE); SCREEN_LINE(cmdline_row + r, 0, cols, cols, FALSE);
} }
ret = 4; ret = 4;
} }

View File

@@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
797,
/**/ /**/
796, 796,
/**/ /**/