To: vim_dev@googlegroups.com Subject: Patch 8.0.0606 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0606 Problem: Cannot set the context for a specified quickfix list. Solution: Use the list index instead of the current list. (Yegappan Lakshmanan) Files: src/quickfix.c, src/testdir/test_quickfix.vim *** ../vim-8.0.0605/src/quickfix.c 2017-05-28 07:56:30.330985871 +0200 --- src/quickfix.c 2017-05-28 08:12:01.305210132 +0200 *************** *** 4881,4887 **** /* Use the specified quickfix/location list */ if (di->di_tv.v_type == VAR_NUMBER) { ! qf_idx = di->di_tv.vval.v_number - 1; if (qf_idx < 0 || qf_idx >= qi->qf_listcount) return FAIL; } --- 4881,4889 ---- /* Use the specified quickfix/location list */ if (di->di_tv.v_type == VAR_NUMBER) { ! /* for zero use the current list */ ! if (di->di_tv.vval.v_number != 0) ! qf_idx = di->di_tv.vval.v_number - 1; if (qf_idx < 0 || qf_idx >= qi->qf_listcount) return FAIL; } *************** *** 4912,4922 **** if ((di = dict_find(what, (char_u *)"context", -1)) != NULL) { typval_T *ctx; ! free_tv(qi->qf_lists[qi->qf_curlist].qf_ctx); ctx = alloc_tv(); if (ctx != NULL) copy_tv(&di->di_tv, ctx); ! qi->qf_lists[qi->qf_curlist].qf_ctx = ctx; } return retval; --- 4914,4924 ---- if ((di = dict_find(what, (char_u *)"context", -1)) != NULL) { typval_T *ctx; ! free_tv(qi->qf_lists[qf_idx].qf_ctx); ctx = alloc_tv(); if (ctx != NULL) copy_tv(&di->di_tv, ctx); ! qi->qf_lists[qf_idx].qf_ctx = ctx; } return retval; *** ../vim-8.0.0605/src/testdir/test_quickfix.vim 2017-04-30 14:20:53.342830874 +0200 --- src/testdir/test_quickfix.vim 2017-05-28 08:12:01.305210132 +0200 *************** *** 1804,1809 **** --- 1804,1840 ---- call setloclist(0, [], 'f') call assert_equal({}, getloclist(0, {'context':1})) endif + + " Test for changing the context of previous quickfix lists + call g:Xsetlist([], 'f') + Xexpr "One" + Xexpr "Two" + Xexpr "Three" + call g:Xsetlist([], ' ', {'context' : [1], 'nr' : 1}) + call g:Xsetlist([], ' ', {'context' : [2], 'nr' : 2}) + " Also, check for setting the context using quickfix list number zero. + call g:Xsetlist([], ' ', {'context' : [3], 'nr' : 0}) + call test_garbagecollect_now() + let l = g:Xgetlist({'nr' : 1, 'context' : 1}) + call assert_equal([1], l.context) + let l = g:Xgetlist({'nr' : 2, 'context' : 1}) + call assert_equal([2], l.context) + let l = g:Xgetlist({'nr' : 3, 'context' : 1}) + call assert_equal([3], l.context) + + " Test for changing the context through reference and for garbage + " collection of quickfix context + let l = ["red"] + call g:Xsetlist([], ' ', {'context' : l}) + call add(l, "blue") + let x = g:Xgetlist({'context' : 1}) + call add(x.context, "green") + call assert_equal(["red", "blue", "green"], l) + call assert_equal(["red", "blue", "green"], x.context) + unlet l + call test_garbagecollect_now() + let m = g:Xgetlist({'context' : 1}) + call assert_equal(["red", "blue", "green"], m.context) endfunc func Test_qf_property() *************** *** 2073,2075 **** --- 2104,2122 ---- call XfreeTests('c') call XfreeTests('l') endfunc + + " Test for buffer overflow when parsing lines and adding new entries to + " the quickfix list. + func Test_bufoverflow() + set efm=%f:%l:%m + cgetexpr ['File1:100:' . repeat('x', 1025)] + + set efm=%+GCompiler:\ %.%#,%f:%l:%m + cgetexpr ['Compiler: ' . repeat('a', 1015), 'File1:10:Hello World'] + + set efm=%DEntering\ directory\ %f,%f:%l:%m + cgetexpr ['Entering directory ' . repeat('a', 1006), + \ 'File1:10:Hello World'] + set efm&vim + endfunc + *** ../vim-8.0.0605/src/version.c 2017-05-28 07:56:30.330985871 +0200 --- src/version.c 2017-05-28 08:14:47.728176558 +0200 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 606, /**/ -- FIRST VILLAGER: We have found a witch. May we burn her? "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///