Skip to content

Commit 2b946c9

Browse files
committed
patch 8.0.0079
Problem: Accessing freed memory in quickfix. (Domenique Pelle) Solution: Do not free the current list when adding to it.
1 parent 63bed3d commit 2b946c9

File tree

3 files changed

+142
-124
lines changed

3 files changed

+142
-124
lines changed

src/quickfix.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ qf_init_ext(
11121112
qffields_T fields = {NULL, NULL, 0, 0L, 0, FALSE, NULL, 0, 0, 0};
11131113
#ifdef FEAT_WINDOWS
11141114
qfline_T *old_last = NULL;
1115+
int adding = FALSE;
11151116
#endif
11161117
static efm_T *fmt_first = NULL;
11171118
char_u *efm;
@@ -1140,6 +1141,7 @@ qf_init_ext(
11401141
else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
11411142
{
11421143
/* Adding to existing list, use last entry. */
1144+
adding = TRUE;
11431145
old_last = qi->qf_lists[qi->qf_curlist].qf_last;
11441146
}
11451147
#endif
@@ -1266,10 +1268,13 @@ qf_init_ext(
12661268
}
12671269
EMSG(_(e_readerrf));
12681270
error2:
1269-
qf_free(qi, qi->qf_curlist);
1270-
qi->qf_listcount--;
1271-
if (qi->qf_curlist > 0)
1272-
--qi->qf_curlist;
1271+
if (!adding)
1272+
{
1273+
qf_free(qi, qi->qf_curlist);
1274+
qi->qf_listcount--;
1275+
if (qi->qf_curlist > 0)
1276+
--qi->qf_curlist;
1277+
}
12731278
qf_init_end:
12741279
if (state.fd != NULL)
12751280
fclose(state.fd);

0 commit comments

Comments
 (0)