]> granicus.if.org Git - vim/commitdiff
patch 8.2.2510: internal error when popup with mask is zero height or width v8.2.2510
authorBram Moolenaar <Bram@vim.org>
Sat, 13 Feb 2021 20:31:18 +0000 (21:31 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 13 Feb 2021 20:31:18 +0000 (21:31 +0100)
Problem:    Internal error when popup with mask is zero height or width.
Solution:   Bail out if width or height is zero. (closes #7831)

src/popupwin.c
src/testdir/test_popupwin.vim
src/version.c

index b0895528e933f3900d37a93ee9953a35e78d4397..1122f48e72e92f0ebe74d2c1834c2cdfd8406b18 100644 (file)
@@ -3331,8 +3331,12 @@ popup_update_mask(win_T *wp, int width, int height)
     char_u     *cells;
     int                row, col;
 
-    if (wp->w_popup_mask == NULL)
+    if (wp->w_popup_mask == NULL || width == 0 || height == 0)
+    {
+       vim_free(wp->w_popup_mask_cells);
+       wp->w_popup_mask_cells = NULL;
        return;
+    }
     if (wp->w_popup_mask_cells != NULL
            && wp->w_popup_mask_height == height
            && wp->w_popup_mask_width == width)
index 7f5895f9673e0c882d571aeea68f66b31fd64dcd..44b18005fd051f63fbebf1d482ca268267b92e3e 100644 (file)
@@ -825,6 +825,25 @@ func Test_popup_with_mask()
   " this was causing a crash
   call popup_create('test', #{mask: [[0, 0, 0, 0]]})
   call popup_clear()
+
+  " this was causing an internal error
+  enew
+  set nowrap
+  call repeat('x', &columns)->setline(1)
+  call prop_type_add('textprop', {})
+  call prop_add(1, 1, #{length: &columns, type: 'textprop'})
+  vsplit
+  let opts = popup_create('', #{textprop: 'textprop'})
+       \ ->popup_getoptions()
+       \ ->extend(#{mask: [[1, 1, 1, 1]]})
+  call popup_create('', opts)
+  redraw
+
+  close!
+  bwipe!
+  call prop_type_delete('textprop')
+  call popup_clear()
+  set wrap&
 endfunc
 
 func Test_popup_select()
index 5601c58aa37f152b9176a7bfbf27aa2a18ad841a..264df9bf11ffe05683d9016995b3fcea4b803a79 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2510,
 /**/
     2509,
 /**/