vim-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: vim/vim#19667

Supported by AI

8d13b8244a

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2026-03-15 06:26:21 +08:00
parent 8c2b6d6062
commit 80684a418b
2 changed files with 16 additions and 0 deletions

View File

@@ -815,6 +815,7 @@ retry:
// Copy the read part of the line, excluding null-terminator
memcpy(state->growbuf, IObuff, IOSIZE - 1);
size_t growbuflen = state->linelen;
state->growbuf[growbuflen] = NUL;
while (true) {
errno = 0;

View File

@@ -7014,4 +7014,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