Patch 9.0.0598
Problem: Using negative array index with negative width window.
Solution: Make sure the window width does not become negative.
Files: src/window.c, src/testdir/test_cmdwin.vim
*** ../vim-9.0.0597/src/window.c 2022-09-23 12:56:49.305714732 +0100
--- src/window.c 2022-09-26 23:00:19.267673604 +0100
***************
*** 2089,2094 ****
--- 2089,2096 ----
if (hnc) // add next_curwin size
{
next_curwin_size -= p_wiw - (m - n);
+ if (next_curwin_size < 0)
+ next_curwin_size = 0;
new_size += next_curwin_size;
room -= new_size - next_curwin_size;
}
***************
*** 6611,6617 ****
void
win_new_width(win_T *wp, int width)
{
! wp->w_width = width;
wp->w_lines_valid = 0;
changed_line_abv_curs_win(wp);
// Handled in win_fix_scroll()
--- 6613,6620 ----
void
win_new_width(win_T *wp, int width)
{
! // Should we give an error if width < 0?
! wp->w_width = width < 0 ? 0 : width;
wp->w_lines_valid = 0;
changed_line_abv_curs_win(wp);
// Handled in win_fix_scroll()
*** ../vim-9.0.0597/src/testdir/test_cmdwin.vim 2022-09-18 15:03:18.351501363
+0100
--- src/testdir/test_cmdwin.vim 2022-09-26 23:00:14.183648820 +0100
***************
*** 404,408 ****
--- 404,430 ----
bwipe!
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-9.0.0597/src/version.c 2022-09-26 20:48:28.683453345 +0100
--- src/version.c 2022-09-26 23:02:51.600283059 +0100
***************
*** 701,702 ****
--- 701,704 ----
{ /* Add new patch number below this line */
+ /**/
+ 598,
/**/
--
hundred-and-one symptoms of being an internet addict:
188. You purchase a laptop so you can surf while sitting on the can.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220926221946.2DE501C137B%40moolenaar.net.