To: vim_dev@googlegroups.com Subject: Patch 7.4.1592 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1592 Problem: Quickfix code using memory after being freed. (Dominique Pelle) Solution: Detect that the window was closed. (Hirohito Higashi) Files: src/quickfix.c, src/testdir/test_quickfix.vim *** ../vim-7.4.1591/src/quickfix.c 2016-03-18 21:00:47.876721205 +0100 --- src/quickfix.c 2016-03-19 13:30:43.292493328 +0100 *************** *** 1795,1802 **** --- 1795,1813 ---- oldwin == curwin ? curwin : NULL); } else + { ok = buflist_getfile(qf_ptr->qf_fnum, (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit); + if (qi != &ql_info && !win_valid(oldwin)) + { + EMSG(_("E924: Current window was closed")); + ok = FALSE; + qi = NULL; + qf_ptr = NULL; + opened_window = FALSE; + } + } + } if (ok == OK) *************** *** 1899,1905 **** if (opened_window) win_close(curwin, TRUE); /* Close opened window */ #endif ! if (qf_ptr->qf_fnum != 0) { /* * Couldn't open file, so put index back where it was. This could --- 1910,1916 ---- if (opened_window) win_close(curwin, TRUE); /* Close opened window */ #endif ! if (qf_ptr != NULL && qf_ptr->qf_fnum != 0) { /* * Couldn't open file, so put index back where it was. This could *************** *** 1913,1920 **** } } theend: ! qi->qf_lists[qi->qf_curlist].qf_ptr = qf_ptr; ! qi->qf_lists[qi->qf_curlist].qf_index = qf_index; #ifdef FEAT_WINDOWS if (p_swb != old_swb && opened_window) { --- 1924,1934 ---- } } theend: ! if (qi != NULL) ! { ! qi->qf_lists[qi->qf_curlist].qf_ptr = qf_ptr; ! qi->qf_lists[qi->qf_curlist].qf_index = qf_index; ! } #ifdef FEAT_WINDOWS if (p_swb != old_swb && opened_window) { *** ../vim-7.4.1591/src/testdir/test_quickfix.vim 2016-03-18 21:00:47.876721205 +0100 --- src/testdir/test_quickfix.vim 2016-03-19 13:24:42.496268175 +0100 *************** *** 495,497 **** --- 495,516 ---- augroup! testgroup endfunction + + function Test_locationlist_curwin_was_closed() + augroup testgroup + au! + autocmd BufReadCmd t call R(expand("")) + augroup END + + function R(n) + quit + endfunc + + new + let q = [] + call add(q, {'filename': 't' }) + call setloclist(0, q) + call assert_fails('lrewind', 'E924:') + + augroup! testgroup + endfunction *** ../vim-7.4.1591/src/version.c 2016-03-18 21:00:47.876721205 +0100 --- src/version.c 2016-03-19 13:32:03.315656249 +0100 *************** *** 750,751 **** --- 750,753 ---- { /* Add new patch number below this line */ + /**/ + 1592, /**/ -- hundred-and-one symptoms of being an internet addict: 81. At social functions you introduce your husband as "my domain server." /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///