patch 9.2.0159: Crash when reading quickfix line

Commit: 
https://github.com/vim/vim/commit/8d13b8244a41d2457bc5049bdd0bb0238a754ede
Author: Christian Brabandt <[email protected]>
Date:   Fri Mar 13 21:45:26 2026 +0000

    patch 9.2.0159: Crash when reading quickfix line
    
    Problem:  Crash when reading quickfix line (Kaiyu Xie)
    Solution: Make sure line is terminated by NUL
    
    closes: #19667
    
    Supported by AI
    
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/quickfix.c b/src/quickfix.c
index b6fa2b65d..cffe635ea 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -838,6 +838,7 @@ qf_get_next_file_line(qfstate_T *state)
        // Copy the read part of the line, excluding null-terminator
        memcpy(state->growbuf, IObuff, IOSIZE - 1);
        growbuflen = state->linelen;
+       state->growbuf[growbuflen] = NUL;
 
        for (;;)
        {
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 4c61b6b2e..fd97fd106 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -6992,4 +6992,19 @@ func Test_quickfixtextfunc_wipes_buffer()
   bw
 endfunc
 
+func Test_quickfix_longline_noeol()
+  CheckRunVimInTerminal
+  let qf = 'Xquickfix'
+  let args = $"-q {qf}"
+  let after =<< trim [CODE]
+    call writefile(['okay'], "XDONE")
+    qall!
+  [CODE]
+  defer delete("XDONE")
+  call writefile([repeat('A', 1024)], qf, 'bD')
+  call RunVim([], after, args)
+  call WaitForAssert({-> assert_true(filereadable("XDONE"))})
+  call assert_equal(['okay'], readfile("XDONE"))
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 3874a3778..a55c7a1ab 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    159,
 /**/
     158,
 /**/

-- 
-- 
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 visit 
https://groups.google.com/d/msgid/vim_dev/E1w1AY7-00400s-QU%40256bit.org.

Raspunde prin e-mail lui