]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0149: null pointer member access when accessing 'winfixbuf' property v9.1.0149
authorSean Dewar <6256228+seandewar@users.noreply.github.com>
Mon, 4 Mar 2024 18:09:26 +0000 (19:09 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 4 Mar 2024 18:09:26 +0000 (19:09 +0100)
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 <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/quickfix.c
src/testdir/test_winfixbuf.vim
src/version.c

index 1f4176fe5427b66ebf12e18521fe79f16eed43ec..02a69d28c3694eac66848024014dca52e2b61acc 100644 (file)
@@ -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;
index 0b15983932ada2ba92eb4b5779847f5897d94bfd..2dffbe1f03b47d87127a63900521ab52dd7e7015 100644 (file)
@@ -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
index cecf0892b36de52d3c221c57e5a6c9c0dfe1369c..46781f0279ad008b8052a292cf2e3d22874c50ef 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    149,
 /**/
     148,
 /**/