Skip to content

Commit 63bed3d

Browse files
committed
patch 8.0.0078
Problem: Accessing freed memory in quickfix. Solution: Reset pointer when freeing 'errorformat'. (Domenique Pelle)
1 parent e3505df commit 63bed3d

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/quickfix.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ struct efm_S
114114
int conthere; /* %> used */
115115
};
116116

117+
static efm_T *fmt_start = NULL; /* cached across qf_parse_line() calls */
118+
117119
static int qf_init_ext(qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast, char_u *qf_title);
118120
static void qf_store_title(qf_info_T *qi, char_u *title);
119121
static void qf_new_list(qf_info_T *qi, char_u *qf_title);
@@ -389,6 +391,7 @@ free_efm_list(efm_T **efm_first)
389391
vim_regfree(efm_ptr->prog);
390392
vim_free(efm_ptr);
391393
}
394+
fmt_start = NULL;
392395
}
393396

394397
/* Parse 'errorformat' option */
@@ -786,7 +789,6 @@ qf_parse_line(
786789
qffields_T *fields)
787790
{
788791
efm_T *fmt_ptr;
789-
static efm_T *fmt_start = NULL; /* cached across calls */
790792
char_u *ptr;
791793
int len;
792794
int i;

src/testdir/test_quickfix.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,3 +1648,13 @@ function! Test_Autocmd_Exception()
16481648

16491649
set efm&vim
16501650
endfunction
1651+
1652+
function Test_caddbuffer()
1653+
" This used to cause a memory access in freed memory
1654+
let save_efm = &efm
1655+
set efm=%EEEE%m,%WWWW,%+CCCC%>%#,%GGGG%.#
1656+
cgetexpr ['WWWW', 'EEEE', 'CCCC']
1657+
let &efm = save_efm
1658+
cad
1659+
bwipe!
1660+
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+
78,
767769
/**/
768770
77,
769771
/**/

0 commit comments

Comments
 (0)