diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-07-25 22:53:00 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-07-25 22:53:00 +0200 |
commit | 5f95f288a2d303be1571e818655fd90e399ee58e (patch) | |
tree | f98713d8c077018e5ac90307999127aab820475d /src/screen.c | |
parent | 33c3a694fca7978cdd28c5e41b498473a08bc05e (diff) | |
download | vim-5f95f288a2d303be1571e818655fd90e399ee58e.zip |
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.
Diffstat (limited to 'src/screen.c')
-rw-r--r-- | src/screen.c | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/src/screen.c b/src/screen.c index e1547624c..ba964b495 100644 --- a/src/screen.c +++ b/src/screen.c @@ -279,6 +279,7 @@ redraw_asap(type) int type; { int rows; + int cols = screen_Columns; int r; int ret = 0; schar_T *screenline; /* copy from ScreenLines[] */ @@ -291,28 +292,28 @@ redraw_asap(type) #endif redraw_later(type); - if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY)) + if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY) || exiting) return ret; /* 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( - (long_u)(rows * Columns * sizeof(schar_T)), FALSE); + (long_u)(rows * cols * sizeof(schar_T)), FALSE); 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) ret = 2; #ifdef FEAT_MBYTE if (enc_utf8) { screenlineUC = (u8char_T *)lalloc( - (long_u)(rows * Columns * sizeof(u8char_T)), FALSE); + (long_u)(rows * cols * sizeof(u8char_T)), FALSE); if (screenlineUC == NULL) ret = 2; for (i = 0; i < p_mco; ++i) { 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) ret = 2; } @@ -320,7 +321,7 @@ redraw_asap(type) if (enc_dbcs == DBCS_JPNU) { screenline2 = (schar_T *)lalloc( - (long_u)(rows * Columns * sizeof(schar_T)), FALSE); + (long_u)(rows * cols * sizeof(schar_T)), FALSE); if (screenline2 == NULL) ret = 2; } @@ -331,27 +332,27 @@ redraw_asap(type) /* Save the text displayed in the command line area. */ for (r = 0; r < rows; ++r) { - mch_memmove(screenline + r * Columns, + mch_memmove(screenline + r * cols, ScreenLines + LineOffset[cmdline_row + r], - (size_t)Columns * sizeof(schar_T)); - mch_memmove(screenattr + r * Columns, + (size_t)cols * sizeof(schar_T)); + mch_memmove(screenattr + r * cols, ScreenAttrs + LineOffset[cmdline_row + r], - (size_t)Columns * sizeof(sattr_T)); + (size_t)cols * sizeof(sattr_T)); #ifdef FEAT_MBYTE if (enc_utf8) { - mch_memmove(screenlineUC + r * Columns, + mch_memmove(screenlineUC + r * cols, ScreenLinesUC + LineOffset[cmdline_row + r], - (size_t)Columns * sizeof(u8char_T)); + (size_t)cols * sizeof(u8char_T)); for (i = 0; i < p_mco; ++i) - mch_memmove(screenlineC[i] + r * Columns, - ScreenLinesC[r] + LineOffset[cmdline_row + r], - (size_t)Columns * sizeof(u8char_T)); + mch_memmove(screenlineC[i] + r * cols, + ScreenLinesC[i] + LineOffset[cmdline_row + r], + (size_t)cols * sizeof(u8char_T)); } if (enc_dbcs == DBCS_JPNU) - mch_memmove(screenline2 + r * Columns, + mch_memmove(screenline2 + r * cols, ScreenLines2 + LineOffset[cmdline_row + r], - (size_t)Columns * sizeof(schar_T)); + (size_t)cols * sizeof(schar_T)); #endif } @@ -366,28 +367,28 @@ redraw_asap(type) for (r = 0; r < rows; ++r) { mch_memmove(current_ScreenLine, - screenline + r * Columns, - (size_t)Columns * sizeof(schar_T)); + screenline + r * cols, + (size_t)cols * sizeof(schar_T)); mch_memmove(ScreenAttrs + off, - screenattr + r * Columns, - (size_t)Columns * sizeof(sattr_T)); + screenattr + r * cols, + (size_t)cols * sizeof(sattr_T)); #ifdef FEAT_MBYTE if (enc_utf8) { mch_memmove(ScreenLinesUC + off, - screenlineUC + r * Columns, - (size_t)Columns * sizeof(u8char_T)); + screenlineUC + r * cols, + (size_t)cols * sizeof(u8char_T)); for (i = 0; i < p_mco; ++i) mch_memmove(ScreenLinesC[i] + off, - screenlineC[i] + r * Columns, - (size_t)Columns * sizeof(u8char_T)); + screenlineC[i] + r * cols, + (size_t)cols * sizeof(u8char_T)); } if (enc_dbcs == DBCS_JPNU) mch_memmove(ScreenLines2 + off, - screenline2 + r * Columns, - (size_t)Columns * sizeof(schar_T)); + screenline2 + r * cols, + (size_t)cols * sizeof(schar_T)); #endif - SCREEN_LINE(cmdline_row + r, 0, Columns, Columns, FALSE); + SCREEN_LINE(cmdline_row + r, 0, cols, cols, FALSE); } ret = 4; } |