Skip to content

Commit 10ccfb2

Browse files
committed
patch 8.2.2510: internal error when popup with mask is zero height or width
Problem: Internal error when popup with mask is zero height or width. Solution: Bail out if width or height is zero. (closes #7831)
1 parent 8d4be89 commit 10ccfb2

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/popupwin.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3331,8 +3331,12 @@ popup_update_mask(win_T *wp, int width, int height)
33313331
char_u *cells;
33323332
int row, col;
33333333

3334-
if (wp->w_popup_mask == NULL)
3334+
if (wp->w_popup_mask == NULL || width == 0 || height == 0)
3335+
{
3336+
vim_free(wp->w_popup_mask_cells);
3337+
wp->w_popup_mask_cells = NULL;
33353338
return;
3339+
}
33363340
if (wp->w_popup_mask_cells != NULL
33373341
&& wp->w_popup_mask_height == height
33383342
&& wp->w_popup_mask_width == width)

src/testdir/test_popupwin.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,25 @@ func Test_popup_with_mask()
825825
" this was causing a crash
826826
call popup_create('test', #{mask: [[0, 0, 0, 0]]})
827827
call popup_clear()
828+
829+
" this was causing an internal error
830+
enew
831+
set nowrap
832+
call repeat('x', &columns)->setline(1)
833+
call prop_type_add('textprop', {})
834+
call prop_add(1, 1, #{length: &columns, type: 'textprop'})
835+
vsplit
836+
let opts = popup_create('', #{textprop: 'textprop'})
837+
\ ->popup_getoptions()
838+
\ ->extend(#{mask: [[1, 1, 1, 1]]})
839+
call popup_create('', opts)
840+
redraw
841+
842+
close!
843+
bwipe!
844+
call prop_type_delete('textprop')
845+
call popup_clear()
846+
set wrap&
828847
endfunc
829848

830849
func Test_popup_select()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2510,
753755
/**/
754756
2509,
755757
/**/

0 commit comments

Comments
 (0)