Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Segmentation fault when complete() called after complete_add() #1668

@lifepillar

Description

@lifepillar

I can consistently segfault Vim 8.0.586 (installed with Homebrew on macOS) using the following code:

fun! CompleteMonths()
  for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep")
      call complete_add(m)
    if complete_check()
      break
    endif
  endfor
  return []
endfun

fun! CompleteMore()
  call complete(1, split("Oct Nov Dec"))
  return []
endfun

fun! MyComplete(findstart, base)
  if a:findstart
    let line = getline('.')
    let start = col('.') - 1
    while start > 0 && line[start - 1] =~ '\a'
      let start -= 1
    endwhile
    return start
  else
    call CompleteMonths()
    call CompleteMore()
    return []
  endif
endf

set completefunc=MyComplete

" Ju

Source it, put the cursor at the end after Ju and type <c-x><c-u>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions