]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0989: crash after resizing a terminal window v8.2.0989
authorBram Moolenaar <Bram@vim.org>
Tue, 16 Jun 2020 18:58:07 +0000 (20:58 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 16 Jun 2020 18:58:07 +0000 (20:58 +0200)
Problem:    Crash after resizing a terminal window. (August Masquelier)
Solution:   Add check for valid row in libvterm. (closes #6273)

src/libvterm/src/screen.c
src/libvterm/src/state.c
src/version.c

index 3e72e4bbe6f793ad930286af1c624bcafa7a9a70..e5d740b2d6ea02351aa21f4cacfc53a8ff66e115 100644 (file)
@@ -280,6 +280,12 @@ static int erase_internal(VTermRect rect, int selective, void *user)
     for(col = rect.start_col; col < rect.end_col; col++) {
       ScreenCell *cell = getcell(screen, row, col);
 
+      if (cell == NULL)
+      {
+        DEBUG_LOG2("libvterm: erase_internal() position invalid: %d / %d",
+                                                                    row, col);
+       return 1;
+      }
       if(selective && cell->pen.protected_cell)
         continue;
 
index a621822333731a216f9922995c64f33c98d70ce2..dd25726db1e24281e7d4329ea36fa295e6544649 100644 (file)
@@ -16,6 +16,12 @@ static int on_resize(int rows, int cols, void *user);
 static void putglyph(VTermState *state, const uint32_t chars[], int width, VTermPos pos)
 {
   VTermGlyphInfo info;
+
+  if (pos.row >= state->rows)
+  {
+    DEBUG_LOG2("libvterm: putglyph() pos.row %d out of range (rows = %d)\n", pos.row, state.rows);
+    return;
+  }
   info.chars = chars;
   info.width = width;
   info.protected_cell = state->protected_cell;
@@ -283,6 +289,11 @@ static int on_text(const char bytes[], size_t len, void *user)
 
   VTermPos oldpos = state->pos;
 
+  if (state->pos.row >= state->rows)
+  {
+    DEBUG_LOG2("libvterm: on_text() pos.row %d out of range (rows = %d)\n", state->pos.row, state.rows);
+    return 0;
+  }
   // We'll have at most len codepoints, plus one from a previous incomplete
   // sequence.
   codepoints = vterm_allocator_malloc(state->vt, (len + 1) * sizeof(uint32_t));
index e1a41fb435a2c54ebd53c4672de0ae5e6d4d55ac..d69b5608fb9436a6400ba802cbc698e76bf9724f 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    989,
 /**/
     988,
 /**/