patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property

Commit: 
https://github.com/vim/vim/commit/5131f224da93f2e042a4b22545ef62b1b2ab8460
Author: Sean Dewar <[email protected]>
Date:   Mon Mar 4 19:09:26 2024 +0100

    patch 9.1.0149: null pointer member access when accessing 'winfixbuf' 
property
    
    Problem:  qf_goto_win_with_qfl_file may check if prevwin has 'winfixbuf'
              set without checking if it's valid first.
    Solution: Reverse the condition. Add a test, a modeline, and a missing
              CheckFeature. (Searn Dewar)
    
    closes: #14140
    
    Signed-off-by: Sean Dewar <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/quickfix.c b/src/quickfix.c
index 1f4176fe5..02a69d28c 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3146,7 +3146,7 @@ qf_goto_win_with_qfl_file(int qf_fnum)
            // Didn't find it, go to the window before the quickfix
            // window, unless 'switchbuf' contains 'uselast': in this case we
            // try to jump to the previously used window first.
-           if ((swb_flags & SWB_USELAST) && !prevwin->w_p_wfb && 
win_valid(prevwin))
+           if ((swb_flags & SWB_USELAST) && win_valid(prevwin) && 
!prevwin->w_p_wfb)
                win = prevwin;
            else if (altwin != NULL)
                win = altwin;
diff --git a/src/testdir/test_winfixbuf.vim b/src/testdir/test_winfixbuf.vim
index 0b1598393..2dffbe1f0 100644
--- a/src/testdir/test_winfixbuf.vim
+++ b/src/testdir/test_winfixbuf.vim
@@ -1576,6 +1576,7 @@ endfunc
 
 " Fail vim.command if we try to change buffers while 'winfixbuf' is set
 func Test_lua_command()
+  CheckFeature lua
   call s:reset_all_buffers()
 
   enew
@@ -3129,3 +3130,21 @@ func Test_wprevious()
   call delete("middle")
   call delete("last")
 endfunc
+
+func Test_quickfix_switchbuf_invalid_prevwin()
+  call s:reset_all_buffers()
+
+  let [l:first, _] = s:make_simple_quickfix()
+  call assert_notequal(l:first, bufnr())
+  call assert_equal(1, winnr('$'))
+
+  set switchbuf=uselast
+  split
+  copen
+  execute winnr('#') 'quit'
+
+  call assert_fails('cfirst', 'E1513:')
+  set switchbuf&
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index cecf0892b..46781f027 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    149,
 /**/
     148,
 /**/

-- 
-- 
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/E1rhCq8-00H2mX-9W%40256bit.org.

Raspunde prin e-mail lui