To: vim_dev@googlegroups.com Subject: Patch 9.0.0389 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0389 Problem: Crash when 'tagfunc' closes the window. Solution: Bail out when the window was closed. Files: src/errors.h, src/tag.c, src/testdir/test_tagfunc.vim *** ../vim-9.0.0388/src/errors.h 2022-09-01 12:22:19.743659145 +0100 --- src/errors.h 2022-09-05 19:26:23.610398721 +0100 *************** *** 3324,3326 **** --- 3324,3328 ---- EXTERN char e_non_null_list_required_for_argument_nr[] INIT(= N_("E1298: Non-NULL List required for argument %d")); #endif + EXTERN char e_window_unexpectedly_close_while_searching_for_tags[] + INIT(= N_("E1299: Window unexpectedly closed while searching for tags")); *** ../vim-9.0.0388/src/tag.c 2022-09-03 12:59:15.326103296 +0100 --- src/tag.c 2022-09-05 19:45:15.793045793 +0100 *************** *** 690,695 **** --- 690,705 ---- max_num_matches = MAXCOL; // If less than max_num_matches // found: all matches found. + // A tag function may do anything, which may cause various + // information to become invalid. At least check for the tagstack + // to still be the same. + if (tagstack != curwin->w_tagstack) + { + emsg(_(e_window_unexpectedly_close_while_searching_for_tags)); + FreeWild(new_num_matches, new_matches); + break; + } + // If there already were some matches for the same name, move them // to the start. Avoids that the order changes when using // ":tnext" and jumping to another file. *** ../vim-9.0.0388/src/testdir/test_tagfunc.vim 2022-08-22 16:35:41.698700428 +0100 --- src/testdir/test_tagfunc.vim 2022-09-05 19:49:12.877306146 +0100 *************** *** 401,404 **** --- 401,417 ---- set tagfunc= endfunc + func Test_tagfunc_closes_window() + split any + func MytagfuncClose(pat, flags, info) + close + return [{'name' : 'mytag', 'filename' : 'Xtest', 'cmd' : '1'}] + endfunc + set tagfunc=MytagfuncClose + call assert_fails('tag xyz', 'E1299:') + + set tagfunc= + endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.0388/src/version.c 2022-09-05 18:27:38.847160366 +0100 --- src/version.c 2022-09-05 19:26:12.074422359 +0100 *************** *** 705,706 **** --- 705,708 ---- { /* Add new patch number below this line */ + /**/ + 389, /**/ -- hundred-and-one symptoms of being an internet addict: 8. You spend half of the plane trip with your laptop on your lap...and your child in the overhead compartment. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///