mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 05:58:33 +00:00
vim-patch:9.0.0598: using negative array index with negative width window
Problem: Using negative array index with negative width window.
Solution: Make sure the window width does not become negative.
8279af514c
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -2304,6 +2304,9 @@ static void win_equal_rec(win_T *next_curwin, bool current, frame_T *topfr, int
|
|||||||
}
|
}
|
||||||
if (hnc) { // add next_curwin size
|
if (hnc) { // add next_curwin size
|
||||||
next_curwin_size -= (int)p_wiw - (m - n);
|
next_curwin_size -= (int)p_wiw - (m - n);
|
||||||
|
if (next_curwin_size < 0) {
|
||||||
|
next_curwin_size = 0;
|
||||||
|
}
|
||||||
new_size += next_curwin_size;
|
new_size += next_curwin_size;
|
||||||
room -= new_size - next_curwin_size;
|
room -= new_size - next_curwin_size;
|
||||||
} else {
|
} else {
|
||||||
@@ -6686,7 +6689,8 @@ static int win_border_width(win_T *wp)
|
|||||||
/// Set the width of a window.
|
/// Set the width of a window.
|
||||||
void win_new_width(win_T *wp, int width)
|
void win_new_width(win_T *wp, int width)
|
||||||
{
|
{
|
||||||
wp->w_width = width;
|
// Should we give an error if width < 0?
|
||||||
|
wp->w_width = width < 0 ? 0 : width;
|
||||||
wp->w_pos_changed = true;
|
wp->w_pos_changed = true;
|
||||||
win_set_inner_size(wp, true);
|
win_set_inner_size(wp, true);
|
||||||
}
|
}
|
||||||
|
@@ -41,5 +41,27 @@ func Test_cmdwin_freed_buffer_ptr()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" This was resulting in a window with negative width.
|
||||||
|
" The test doesn't reproduce the illegal memory access though...
|
||||||
|
func Test_cmdwin_split_often()
|
||||||
|
let lines = &lines
|
||||||
|
let columns = &columns
|
||||||
|
set t_WS=
|
||||||
|
|
||||||
|
try
|
||||||
|
" set encoding=iso8859
|
||||||
|
set ruler
|
||||||
|
winsize 0 0
|
||||||
|
noremap 0 H
|
||||||
|
sil norm 0000000q:
|
||||||
|
catch /E36:/
|
||||||
|
endtry
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
set encoding=utf8
|
||||||
|
let &lines = lines
|
||||||
|
let &columns = columns
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user