comparison src/quickfix.c @ 10369:4e5b307638cb v8.0.0079

commit https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 12 18:14:44 2016 +0100 patch 8.0.0079 Problem: Accessing freed memory in quickfix. (Domenique Pelle) Solution: Do not free the current list when adding to it.
author Christian Brabandt <cb@256bit.org>
date Sat, 12 Nov 2016 18:15:04 +0100
parents 4e4e116e3689
children 73e2a7abe2a3
comparison
equal deleted inserted replaced
10368:5af80d389b65 10369:4e5b307638cb
1110 qfstate_T state = {NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, 1110 qfstate_T state = {NULL, 0, NULL, 0, NULL, NULL, NULL, NULL,
1111 NULL, 0, 0}; 1111 NULL, 0, 0};
1112 qffields_T fields = {NULL, NULL, 0, 0L, 0, FALSE, NULL, 0, 0, 0}; 1112 qffields_T fields = {NULL, NULL, 0, 0L, 0, FALSE, NULL, 0, 0, 0};
1113 #ifdef FEAT_WINDOWS 1113 #ifdef FEAT_WINDOWS
1114 qfline_T *old_last = NULL; 1114 qfline_T *old_last = NULL;
1115 int adding = FALSE;
1115 #endif 1116 #endif
1116 static efm_T *fmt_first = NULL; 1117 static efm_T *fmt_first = NULL;
1117 char_u *efm; 1118 char_u *efm;
1118 static char_u *last_efm = NULL; 1119 static char_u *last_efm = NULL;
1119 int retval = -1; /* default: return error flag */ 1120 int retval = -1; /* default: return error flag */
1138 qf_new_list(qi, qf_title); 1139 qf_new_list(qi, qf_title);
1139 #ifdef FEAT_WINDOWS 1140 #ifdef FEAT_WINDOWS
1140 else if (qi->qf_lists[qi->qf_curlist].qf_count > 0) 1141 else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
1141 { 1142 {
1142 /* Adding to existing list, use last entry. */ 1143 /* Adding to existing list, use last entry. */
1144 adding = TRUE;
1143 old_last = qi->qf_lists[qi->qf_curlist].qf_last; 1145 old_last = qi->qf_lists[qi->qf_curlist].qf_last;
1144 } 1146 }
1145 #endif 1147 #endif
1146 1148
1147 /* Use the local value of 'errorformat' if it's set. */ 1149 /* Use the local value of 'errorformat' if it's set. */
1264 retval = qi->qf_lists[qi->qf_curlist].qf_count; 1266 retval = qi->qf_lists[qi->qf_curlist].qf_count;
1265 goto qf_init_end; 1267 goto qf_init_end;
1266 } 1268 }
1267 EMSG(_(e_readerrf)); 1269 EMSG(_(e_readerrf));
1268 error2: 1270 error2:
1269 qf_free(qi, qi->qf_curlist); 1271 if (!adding)
1270 qi->qf_listcount--; 1272 {
1271 if (qi->qf_curlist > 0) 1273 qf_free(qi, qi->qf_curlist);
1272 --qi->qf_curlist; 1274 qi->qf_listcount--;
1275 if (qi->qf_curlist > 0)
1276 --qi->qf_curlist;
1277 }
1273 qf_init_end: 1278 qf_init_end:
1274 if (state.fd != NULL) 1279 if (state.fd != NULL)
1275 fclose(state.fd); 1280 fclose(state.fd);
1276 vim_free(fields.namebuf); 1281 vim_free(fields.namebuf);
1277 vim_free(fields.errmsg); 1282 vim_free(fields.errmsg);