Skip to content

Commit 7618e00

Browse files
committed
patch 8.0.0084
Problem: Using freed memory when adding to a quickfix list. (Domenique Pelle) Solution: Clear the directory name.
1 parent 8e63905 commit 7618e00

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/quickfix.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ static char_u *qf_last_bufname = NULL;
16171617
static bufref_T qf_last_bufref = {NULL, 0};
16181618

16191619
/*
1620-
* Get buffer number for file "directory.fname".
1620+
* Get buffer number for file "directory/fname".
16211621
* Also sets the b_has_qf_entry flag.
16221622
*/
16231623
static int
@@ -2711,7 +2711,9 @@ qf_free(qf_info_T *qi, int idx)
27112711
qi->qf_lists[idx].qf_index = 0;
27122712

27132713
qf_clean_dir_stack(&qi->qf_dir_stack);
2714+
qi->qf_directory = NULL;
27142715
qf_clean_dir_stack(&qi->qf_file_stack);
2716+
qi->qf_currfile = NULL;
27152717
}
27162718

27172719
/*

src/testdir/test_quickfix.vim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,3 +1669,25 @@ func Test_caddexpr_wrong()
16691669
call assert_fails('caddexpr ""', 'E376:')
16701670
let &efm = save_efm
16711671
endfunc
1672+
1673+
func Test_dirstack_cleanup()
1674+
" This used to cause a memory access in freed memory.
1675+
let save_efm = &efm
1676+
lexpr '0'
1677+
lopen
1678+
fun X(c)
1679+
let save_efm=&efm
1680+
set efm=%D%f
1681+
if a:c == 'c'
1682+
caddexpr '::'
1683+
else
1684+
laddexpr ':0:0'
1685+
endif
1686+
let &efm=save_efm
1687+
endfun
1688+
call X('c')
1689+
call X('l')
1690+
call setqflist([], 'r')
1691+
caddbuffer
1692+
let &efm = save_efm
1693+
endfunc

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
84,
767769
/**/
768770
83,
769771
/**/

0 commit comments

Comments
 (0)