changeset 21606:66618893eb2a v8.2.1353

patch 8.2.1353: crash when drawing double-wide character in terminal window Commit: https://github.com/vim/vim/commit/8b89614e69b9b2330539d0482e44f4724053e780 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 2 15:05:05 2020 +0200 patch 8.2.1353: crash when drawing double-wide character in terminal window Problem: Crash when drawing double-wide character in terminal window. (Masato Nishihata) Solution: Check getcell() returning NULL. (issue #6141)
author Bram Moolenaar <Bram@vim.org>
date Sun, 02 Aug 2020 15:15:03 +0200
parents e2e607fac96b
children 2fd50654cfac
files src/libvterm/src/screen.c src/testdir/test_terminal.vim src/version.c
diffstat 3 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/libvterm/src/screen.c
+++ b/src/libvterm/src/screen.c
@@ -186,7 +186,12 @@ static int putglyph(VTermGlyphInfo *info
     cell->chars[i] = 0;
 
   for(col = 1; col < info->width; col++)
-    getcell(screen, pos.row, pos.col + col)->chars[0] = (uint32_t)-1;
+  {
+    ScreenCell *onecell = getcell(screen, pos.row, pos.col + col);
+    if (onecell == NULL)
+      break;
+    onecell->chars[0] = (uint32_t)-1;
+  }
 
   rect.start_row = pos.row;
   rect.end_row   = pos.row+1;
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -258,6 +258,21 @@ func Test_terminal_scrape_multibyte()
   call delete('Xtext')
 endfunc
 
+func Test_terminal_one_column()
+  " This creates a terminal, displays a double-wide character and makes the
+  " window one column wide.  This used to cause a crash.
+  let width = &columns
+  botright vert term
+  let buf = bufnr('$')
+  call term_wait(buf, 100)
+  exe "set columns=" .. (width / 2)
+  redraw
+  call term_sendkeys(buf, "キ")
+  call term_wait(buf, 10)
+  exe "set columns=" .. width
+  exe buf . 'bwipe!'
+endfunc
+
 func Test_terminal_scroll()
   call writefile(range(1, 200), 'Xtext')
   if has('win32')
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1353,
+/**/
     1352,
 /**/
     1351,