comparison src/quickfix.c @ 8702:39d6e4f2f748 v7.4.1640

commit https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 23 20:55:42 2016 +0100 patch 7.4.1640 Problem: Crash when an autocommand changes a quickfix list. (Dominique) Solution: Check wether an entry is still valid. (Yegappan Lakshmanan, Hirohito Higashi)
author Christian Brabandt <cb@256bit.org>
date Wed, 23 Mar 2016 21:00:05 +0100
parents 24b43dd167eb
children 4ce26276caeb
comparison
equal deleted inserted replaced
8701:e688797c41ff 8702:39d6e4f2f748
1411 return ds_ptr==NULL? NULL: ds_ptr->dirname; 1411 return ds_ptr==NULL? NULL: ds_ptr->dirname;
1412 1412
1413 } 1413 }
1414 1414
1415 /* 1415 /*
1416 * When loading a file from the quickfix, the auto commands may modify it.
1417 * This may invalidate the current quickfix entry. This function checks
1418 * whether a entry is still present in the quickfix.
1419 * Similar to location list.
1420 */
1421 static int
1422 is_qf_entry_present(qf_info_T *qi, qfline_T *qf_ptr)
1423 {
1424 qf_list_T *qfl;
1425 qfline_T *qfp;
1426 int i;
1427
1428 qfl = &qi->qf_lists[qi->qf_curlist];
1429
1430 /* Search for the entry in the current list */
1431 for (i = 0, qfp = qfl->qf_start; i < qfl->qf_count;
1432 ++i, qfp = qfp->qf_next)
1433 if (qfp == qf_ptr)
1434 break;
1435
1436 if (i == qfl->qf_count) /* Entry is not found */
1437 return FALSE;
1438
1439 return TRUE;
1440 }
1441
1442 /*
1416 * jump to a quickfix line 1443 * jump to a quickfix line
1417 * if dir == FORWARD go "errornr" valid entries forward 1444 * if dir == FORWARD go "errornr" valid entries forward
1418 * if dir == BACKWARD go "errornr" valid entries backward 1445 * if dir == BACKWARD go "errornr" valid entries backward
1419 * if dir == FORWARD_FILE go "errornr" valid entries files backward 1446 * if dir == FORWARD_FILE go "errornr" valid entries files backward
1420 * if dir == BACKWARD_FILE go "errornr" valid entries files backward 1447 * if dir == BACKWARD_FILE go "errornr" valid entries files backward
1792 ECMD_HIDE + ECMD_SET_HELP, 1819 ECMD_HIDE + ECMD_SET_HELP,
1793 oldwin == curwin ? curwin : NULL); 1820 oldwin == curwin ? curwin : NULL);
1794 } 1821 }
1795 else 1822 else
1796 { 1823 {
1824 int old_qf_curlist = qi->qf_curlist;
1825 int is_abort = FALSE;
1826
1797 ok = buflist_getfile(qf_ptr->qf_fnum, 1827 ok = buflist_getfile(qf_ptr->qf_fnum,
1798 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit); 1828 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit);
1799 if (qi != &ql_info && !win_valid(oldwin)) 1829 if (qi != &ql_info && !win_valid(oldwin))
1800 { 1830 {
1801 EMSG(_("E924: Current window was closed")); 1831 EMSG(_("E924: Current window was closed"));
1832 is_abort = TRUE;
1833 opened_window = FALSE;
1834 }
1835 else if (old_qf_curlist != qi->qf_curlist
1836 || !is_qf_entry_present(qi, qf_ptr))
1837 {
1838 if (qi == &ql_info)
1839 EMSG(_("E925: Current quickfix was changed"));
1840 else
1841 EMSG(_("E926: Current location list was changed"));
1842 is_abort = TRUE;
1843 }
1844
1845 if (is_abort)
1846 {
1802 ok = FALSE; 1847 ok = FALSE;
1803 qi = NULL; 1848 qi = NULL;
1804 qf_ptr = NULL; 1849 qf_ptr = NULL;
1805 opened_window = FALSE;
1806 } 1850 }
1807 } 1851 }
1808
1809 } 1852 }
1810 1853
1811 if (ok == OK) 1854 if (ok == OK)
1812 { 1855 {
1813 /* When not switched to another buffer, still need to set pc mark */ 1856 /* When not switched to another buffer, still need to set pc mark */