To: vim_dev@googlegroups.com Subject: Patch 8.0.1408 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1408 Problem: Crash in setqflist(). Solution: Check for string to be NULL. (Dominique Pelle, closes #2464) Files: src/quickfix.c, src/testdir/test_quickfix.vim *** ../vim-8.0.1407/src/quickfix.c 2017-12-18 19:48:34.809669484 +0100 --- src/quickfix.c 2017-12-19 10:16:44.388167544 +0100 *************** *** 4930,4937 **** qf_idx = -1; } } ! else if ((di->di_tv.v_type == VAR_STRING) ! && (STRCMP(di->di_tv.vval.v_string, "$") == 0)) /* Get the last quickfix list number */ qf_idx = qi->qf_listcount - 1; else --- 4930,4938 ---- qf_idx = -1; } } ! else if (di->di_tv.v_type == VAR_STRING ! && di->di_tv.vval.v_string != NULL ! && STRCMP(di->di_tv.vval.v_string, "$") == 0) /* Get the last quickfix list number */ qf_idx = qi->qf_listcount - 1; else *************** *** 5226,5232 **** newlist = FALSE; /* use the specified list */ } else if (di->di_tv.v_type == VAR_STRING ! && STRCMP(di->di_tv.vval.v_string, "$") == 0) { if (qi->qf_listcount > 0) qf_idx = qi->qf_listcount - 1; --- 5227,5234 ---- newlist = FALSE; /* use the specified list */ } else if (di->di_tv.v_type == VAR_STRING ! && di->di_tv.vval.v_string != NULL ! && STRCMP(di->di_tv.vval.v_string, "$") == 0) { if (qi->qf_listcount > 0) qf_idx = qi->qf_listcount - 1; *** ../vim-8.0.1407/src/testdir/test_quickfix.vim 2017-12-18 19:48:34.809669484 +0100 --- src/testdir/test_quickfix.vim 2017-12-19 10:15:22.948573412 +0100 *************** *** 1428,1433 **** --- 1428,1438 ---- call assert_fails("call g:Xsetlist(list1, 0)", 'E928:') endfunc + func Test_setqflist_invalid_nr() + " The following command used to crash Vim + call setqflist([], ' ', {'nr' : $XXX_DOES_NOT_EXIST}) + endfunc + func Test_quickfix_set_list_with_act() call XquickfixSetListWithAct('c') call XquickfixSetListWithAct('l') *************** *** 2946,2951 **** --- 2951,2965 ---- call Xgetlist_empty_tests('l') endfunc + func Test_getqflist_invalid_nr() + " The following commands used to crash Vim + cexpr "" + call getqflist({'nr' : $XXX_DOES_NOT_EXIST_XXX}) + + " Cleanup + call setqflist([], 'r') + endfunc + " Tests for the quickfix/location list changedtick func Xqftick_tests(cchar) call s:setup_commands(a:cchar) *** ../vim-8.0.1407/src/version.c 2017-12-19 10:02:39.065335099 +0100 --- src/version.c 2017-12-19 10:18:06.807733870 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1408, /**/ -- I'm writing a book. I've got the page numbers done. /// 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 ///