Mercurial > vim
changeset 23400:5cc8108914e2 v8.2.2243
patch 8.2.2243: crash when popup mask contains zeroes
Commit: https://github.com/vim/vim/commit/4012d262072a3ac95878c9d061fa985301720ec2
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Dec 29 11:57:46 2020 +0100
patch 8.2.2243: crash when popup mask contains zeroes
Problem: Crash when popup mask contains zeroes.
Solution: Check boundaries properly. (closes https://github.com/vim/vim/issues/7569)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 29 Dec 2020 12:00:49 +0100 |
parents | 8b4c5f00449e |
children | f74a8d305e1e |
files | src/popupwin.c src/testdir/test_popupwin.vim src/version.c |
diffstat | 3 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/popupwin.c +++ b/src/popupwin.c @@ -3346,21 +3346,29 @@ popup_update_mask(win_T *wp, int width, cols = tv_get_number(&li->li_tv); if (cols < 0) cols = width + cols + 1; + if (cols <= 0) + cols = 1; li = li->li_next; cole = tv_get_number(&li->li_tv); if (cole < 0) cole = width + cole + 1; + if (cole > width) + cole = width; li = li->li_next; lines = tv_get_number(&li->li_tv); if (lines < 0) lines = height + lines + 1; + if (lines <= 0) + lines = 1; li = li->li_next; linee = tv_get_number(&li->li_tv); if (linee < 0) linee = height + linee + 1; - - for (row = lines - 1; row < linee && row < height; ++row) - for (col = cols - 1; col < cole && col < width; ++col) + if (linee > height) + linee = height; + + for (row = lines - 1; row < linee; ++row) + for (col = cols - 1; col < cole; ++col) cells[row * width + col] = 1; } }
--- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -821,6 +821,10 @@ func Test_popup_with_mask() " clean up call StopVimInTerminal(buf) call delete('XtestPopupMask') + + " this was causing a crash + call popup_create('test', #{mask: [[0, 0, 0, 0]]}) + call popup_clear() endfunc func Test_popup_select()