1
0
forked from aniani/vim

patch 8.2.1677: memory access errors when calling setloclist() in autocommand

Problem:    Memory access errors when calling setloclist() in an autocommand.
Solution:   Give an error if the list was changed unexpectedly. (closes #6946)
This commit is contained in:
Bram Moolenaar
2020-09-13 22:21:22 +02:00
parent a4224860a4
commit 4d170af0a9
3 changed files with 62 additions and 5 deletions

View File

@@ -1430,6 +1430,30 @@ func Test_quickfix_was_changed_by_autocmd()
call XquickfixChangedByAutocmd('l')
endfunc
func Test_setloclist_in_autocommand()
call writefile(['test1', 'test2'], 'Xfile')
edit Xfile
let s:bufnr = bufnr()
call setloclist(1,
\ [{'bufnr' : s:bufnr, 'lnum' : 1, 'text' : 'test1'},
\ {'bufnr' : s:bufnr, 'lnum' : 2, 'text' : 'test2'}])
augroup Test_LocList
au!
autocmd BufEnter * call setloclist(1,
\ [{'bufnr' : s:bufnr, 'lnum' : 1, 'text' : 'test1'},
\ {'bufnr' : s:bufnr, 'lnum' : 2, 'text' : 'test2'}], 'r')
augroup END
lopen
call assert_fails('exe "normal j\<CR>"', 'E926:')
augroup Test_LocList
au!
augroup END
call delete('Xfile')
endfunc
func Test_caddbuffer_to_empty()
helpgr quickfix
call setqflist([], 'r')