]> granicus.if.org Git - vim/commitdiff
patch 8.2.2244: crash when making the window width negative v8.2.2244
authorBram Moolenaar <Bram@vim.org>
Tue, 29 Dec 2020 11:46:51 +0000 (12:46 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 29 Dec 2020 11:46:51 +0000 (12:46 +0100)
Problem:    Crash when making the window width of the not-current window
            negative.
Solution:   Make sure the window width is not negative. (closes #7568)

src/testdir/test_window_cmd.vim
src/version.c
src/window.c

index 51d0722722013347d38cc2c93d90356f3dfff261..b0c5a417e61bd32a891f31577b122dfbe9ee88af 100644 (file)
@@ -1148,6 +1148,14 @@ func Test_window_resize()
   exe other_winnr .. 'resize +1'
   call assert_equal(12, winheight(other_winnr))
   call assert_equal(&lines - 10 - 3 -2, winheight(0))
+  close
+
+  vsplit
+  wincmd l
+  let other_winnr = winnr('h')
+  call assert_notequal(winnr(), other_winnr)
+  exe 'vert ' .. other_winnr .. 'resize -100'
+  call assert_equal(0, winwidth(other_winnr))
 
   %bwipe!
 endfunc
index 6c6d8c640c3a3b5a9f12cdea672f04941f9199ea..20bd86f763ff1115416aecbea5ec74442463c403 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2244,
 /**/
     2243,
 /**/
index 1cf795fd743aeb1eeb3e70214173196dd78c23f5..bea4f391a890200e93cdb9112ed8bdf4d538de53 100644 (file)
@@ -5687,6 +5687,8 @@ win_setwidth_win(int width, win_T *wp)
        if (width == 0)
            width = 1;
     }
+    else if (width < 0)
+       width = 0;
 
     frame_setwidth(wp->w_frame, width + wp->w_vsep_width);