]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0159: Crash when reading quickfix line v9.2.0159
authorChristian Brabandt <cb@256bit.org>
Fri, 13 Mar 2026 21:45:26 +0000 (21:45 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 13 Mar 2026 21:45:26 +0000 (21:45 +0000)
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 <cb@256bit.org>
src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index b6fa2b65d2b313a9d9cfad3d639f07130b0147bf..cffe635ea21522e74fe9631a3294eedeefe83d71 100644 (file)
@@ -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 (;;)
        {
index 4c61b6b2ee332e01feb94a0882ad034600b1176c..fd97fd106eca9a4f19a4712bd7f0cb9d773255d9 100644 (file)
@@ -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
index 3874a37784200d86853daeee527f4b1e97b367fb..a55c7a1ab69271d2d90b6868590d79acffd9aa38 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    159,
 /**/
     158,
 /**/