0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 7.4.1647

Problem:    Using freed memory after setqflist() and ":caddbuffer".  (Dominique)
Solution:   Set qf_ptr when adding the first item to the quickfix list.
This commit is contained in:
Bram Moolenaar
2016-03-25 15:01:10 +01:00
parent 4c90861e9f
commit 8b20179c65
3 changed files with 14 additions and 1 deletions

View File

@@ -1027,6 +1027,8 @@ qf_add_entry(
/* first element in the list */ /* first element in the list */
{ {
qi->qf_lists[qi->qf_curlist].qf_start = qfp; qi->qf_lists[qi->qf_curlist].qf_start = qfp;
qi->qf_lists[qi->qf_curlist].qf_ptr = qfp;
qi->qf_lists[qi->qf_curlist].qf_index = 0;
qfp->qf_prev = qfp; /* first element points to itself */ qfp->qf_prev = qfp; /* first element points to itself */
} }
else else
@@ -4113,6 +4115,7 @@ set_errorlist(
else else
qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start; qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start;
if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
qi->qf_lists[qi->qf_curlist].qf_index = 1; qi->qf_lists[qi->qf_curlist].qf_index = 1;
#ifdef FEAT_WINDOWS #ifdef FEAT_WINDOWS

View File

@@ -679,3 +679,11 @@ function Test_quickfix_was_changed_by_autocmd()
call XquickfixChangedByAutocmd('c') call XquickfixChangedByAutocmd('c')
call XquickfixChangedByAutocmd('l') call XquickfixChangedByAutocmd('l')
endfunction endfunction
func Test_caddbuffer_to_empty()
helpgr quickfix
call setqflist([], 'r')
cad
call assert_fails('cn', 'E553:')
quit!
endfunc

View File

@@ -748,6 +748,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1647,
/**/ /**/
1646, 1646,
/**/ /**/