]> granicus.if.org Git - vim/commitdiff
patch 8.2.1353: crash when drawing double-wide character in terminal window v8.2.1353
authorBram Moolenaar <Bram@vim.org>
Sun, 2 Aug 2020 13:05:05 +0000 (15:05 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 2 Aug 2020 13:05:05 +0000 (15:05 +0200)
Problem:    Crash when drawing double-wide character in terminal window.
            (Masato Nishihata)
Solution:   Check getcell() returning NULL. (issue #6141)

src/libvterm/src/screen.c
src/testdir/test_terminal.vim
src/version.c

index eb90c200717ab37e6c05ec73426cee0d3a177e30..42890aa58a1f5aec13c99ffe89068c808b75ed06 100644 (file)
@@ -186,7 +186,12 @@ static int putglyph(VTermGlyphInfo *info, VTermPos pos, void *user)
     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;
index fcc11565cdfa121358bcef6945476b9ab125e2fb..c1ee493cd7d8a1a84e6457005731ced795975760 100644 (file)
@@ -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')
index 70d90c5764409a528d4fd397368b3a31ddfbe285..f34402dc6f1d57a20d2ab0f3c54b8e054ee610d1 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1353,
 /**/
     1352,
 /**/