Skip to content

Commit fef6630

Browse files
committed
patch 9.1.0065: Segfault with CompleteChanged autocommand
Problem: Segfault with CompleteChanged autocommand (markonm ) Solution: Test match->cp_prev for being NULL before accessing it closes: #13929 Signed-off-by: Christian Brabandt <[email protected]>
1 parent 6e0a18f commit fef6630

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/insexpand.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3075,7 +3075,8 @@ info_add_completion_info(list_T *li)
30753075

30763076
// Skip the element with the CP_ORIGINAL_TEXT flag at the beginning, in case of
30773077
// forward completion, or at the end, in case of backward completion.
3078-
match = forward ? match->cp_next : (compl_no_select && match_at_original_text(match) ? match->cp_prev : match->cp_prev->cp_prev);
3078+
match = forward || match->cp_prev == NULL ? match->cp_next :
3079+
(compl_no_select && match_at_original_text(match) ? match->cp_prev : match->cp_prev->cp_prev);
30793080

30803081
while (match != NULL && !match_at_original_text(match))
30813082
{

src/testdir/test_ins_complete.vim

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2359,4 +2359,18 @@ func Test_complete_info_index()
23592359
bwipe!
23602360
endfunc
23612361

2362-
" vim: shiftwidth=2 sts=2 expandtab
2362+
func Test_complete_changed_complete_info()
2363+
CheckRunVimInTerminal
2364+
" this used to crash vim, see #13929
2365+
let lines =<< trim END
2366+
set completeopt=menuone
2367+
autocmd CompleteChanged * call complete_info(['items'])
2368+
call feedkeys("iii\<cr>\<c-p>")
2369+
END
2370+
call writefile(lines, 'Xsegfault', 'D')
2371+
let buf = RunVimInTerminal('-S Xsegfault', #{rows: 5})
2372+
call WaitForAssert({-> assert_match('^ii', term_getline(buf, 1))}, 1000)
2373+
call StopVimInTerminal(buf)
2374+
endfunc
2375+
2376+
" vim: shiftwidth=2 sts=2 expandtab nofoldenable

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
65,
707709
/**/
708710
64,
709711
/**/

0 commit comments

Comments
 (0)