Skip to content

Commit

Permalink
fix(float): fix potential heap corruption in win_redr_border
Browse files Browse the repository at this point in the history
  • Loading branch information
zeertzjq committed Oct 27, 2021
1 parent d918759 commit de670f3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/nvim/screen.c
Expand Up @@ -5655,7 +5655,9 @@ static void win_redr_border(win_T *wp)
int ic = (i == 0 && !adj[3] && chars[6][0]) ? 6 : 5;
grid_put_schar(grid, irow+adj[0], i+adj[3], chars[ic], attrs[ic]);
}
grid_put_schar(grid, irow+adj[0], icol+adj[3], chars[4], attrs[4]);
if (adj[1]) {
grid_put_schar(grid, irow+adj[0], icol+adj[3], chars[4], attrs[4]);
}
grid_puts_line_flush(false);
}
}
Expand Down
44 changes: 44 additions & 0 deletions test/functional/ui/float_spec.lua
Expand Up @@ -1194,6 +1194,50 @@ describe('float window', function()
]]}
end

meths.win_set_config(win, {border={"", "_", "", "", "", "-", "", ""}})
if multigrid then
command('redraw!') -- TODO: without a redraw this test fails, which should be fixed
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[3:----------------------------------------]|
## grid 2
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
|
## grid 5
{5:_________}|
{1: halloj! }|
{1: BORDAA }|
{5:---------}|
]], float_pos={
[5] = { { id = 1002 }, "NW", 1, 2, 5, true }
}, win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
[5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2};
}}
else
screen:expect{grid=[[
^ |
{0:~ }|
{0:~ }{5:_________}{0: }|
{0:~ }{1: halloj! }{0: }|
{0:~ }{1: BORDAA }{0: }|
{0:~ }{5:---------}{0: }|
|
]]}
end

insert [[
neeed some dummy
background text
Expand Down

0 comments on commit de670f3

Please sign in to comment.