To: vim_dev@googlegroups.com Subject: Patch 8.2.4831 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4831 Problem: Crash when using maparg() and unmapping simplified keys. Solution: Do not keep a mapblock pointer. (closes #10294) Files: src/map.c, src/testdir/test_map_functions.vim *** ../vim-8.2.4830/src/map.c 2022-04-26 12:29:38.960587911 +0100 --- src/map.c 2022-04-26 21:21:44.831295679 +0100 *************** *** 2325,2332 **** int mode; int abbr = FALSE; int get_dict = FALSE; ! mapblock_T *mp; ! mapblock_T *mp_simplified = NULL; int buffer_local; int flags = REPTERM_FROM_PART | REPTERM_DO_LT; --- 2325,2331 ---- int mode; int abbr = FALSE; int get_dict = FALSE; ! mapblock_T *mp = NULL; int buffer_local; int flags = REPTERM_FROM_PART | REPTERM_DO_LT; *************** *** 2362,2369 **** { // When the lhs is being simplified the not-simplified keys are // preferred for printing, like in do_map(). - // The "rhs" and "buffer_local" values are not expected to change. - mp_simplified = mp; (void)replace_termcodes(keys, &alt_keys_buf, flags | REPTERM_NO_SIMPLIFY, NULL); rhs = check_map(alt_keys_buf, mode, exact, FALSE, abbr, &mp, --- 2361,2366 ---- *************** *** 2384,2390 **** } else if (rettv_dict_alloc(rettv) != FAIL && rhs != NULL) mapblock2dict(mp, rettv->vval.v_dict, ! did_simplify ? mp_simplified->m_keys : NULL, buffer_local); vim_free(keys_buf); vim_free(alt_keys_buf); --- 2381,2387 ---- } else if (rettv_dict_alloc(rettv) != FAIL && rhs != NULL) mapblock2dict(mp, rettv->vval.v_dict, ! did_simplify ? keys_simplified : NULL, buffer_local); vim_free(keys_buf); vim_free(alt_keys_buf); *** ../vim-8.2.4830/src/testdir/test_map_functions.vim 2022-04-25 14:37:42.410308492 +0100 --- src/testdir/test_map_functions.vim 2022-04-26 21:21:44.831295679 +0100 *************** *** 74,79 **** --- 74,85 ---- call assert_equal(['{', 'w', 's'], [d.lhs, d.rhs, d.mode]) sunmap { + map foo + unmap + " This used to cause a segfault + call maparg('', '', 0, 1) + unmap + map abc call assert_equal("", maparg('abc')) unmap abc *************** *** 82,87 **** --- 88,94 ---- let d = maparg('esc', 'i', 1, 1) call assert_equal(['esc', "\\\", '!'], [d.lhs, d.rhs, d.mode]) abclear + unlet d endfunc def Test_vim9_maparg() *** ../vim-8.2.4830/src/version.c 2022-04-26 18:52:17.605206275 +0100 --- src/version.c 2022-04-26 21:32:55.634411586 +0100 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 4831, /**/ -- hundred-and-one symptoms of being an internet addict: 63. You start using smileys in your snail mail. /// 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 ///