To: vim_dev@googlegroups.com Subject: Patch 8.2.1952 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1952 Problem: Vim9: crash when using a NULL dict key. Solution: Use a NULL dict key like an empty string. (closes #7249) Files: src/vim9execute.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1951/src/vim9execute.c 2020-10-30 21:49:36.302568284 +0100 --- src/vim9execute.c 2020-11-04 13:20:45.184373664 +0100 *************** *** 1738,1743 **** --- 1738,1744 ---- int count = iptr->isn_arg.number; dict_T *dict = dict_alloc(); dictitem_T *item; + char_u *key; if (dict == NULL) goto failed; *************** *** 1746,1760 **** // have already checked key type is VAR_STRING tv = STACK_TV_BOT(2 * (idx - count)); // check key is unique ! item = dict_find(dict, tv->vval.v_string, -1); if (item != NULL) { SOURCING_LNUM = iptr->isn_lnum; ! semsg(_(e_duplicate_key), tv->vval.v_string); dict_unref(dict); goto on_error; } ! item = dictitem_alloc(tv->vval.v_string); clear_tv(tv); if (item == NULL) { --- 1747,1763 ---- // have already checked key type is VAR_STRING tv = STACK_TV_BOT(2 * (idx - count)); // check key is unique ! key = tv->vval.v_string == NULL ! ? (char_u *)"" : tv->vval.v_string; ! item = dict_find(dict, key, -1); if (item != NULL) { SOURCING_LNUM = iptr->isn_lnum; ! semsg(_(e_duplicate_key), key); dict_unref(dict); goto on_error; } ! item = dictitem_alloc(key); clear_tv(tv); if (item == NULL) { *** ../vim-8.2.1951/src/testdir/test_vim9_expr.vim 2020-11-04 12:00:46.656717337 +0100 --- src/testdir/test_vim9_expr.vim 2020-11-04 13:37:17.845648950 +0100 *************** *** 1902,1907 **** --- 1902,1909 ---- var dictdict: dict> = #{one: #{a: 'text'}, two: #{}} dictdict = #{one: #{}, two: #{a: 'text'}} dictdict = #{one: #{}, two: #{}} + + assert_equal({'': 0}, {matchstr('string', 'wont match'): 0}) CheckDefFailure(["var x = #{a:8}"], 'E1069:', 1) CheckDefFailure(["var x = #{a : 8}"], 'E1068:', 1) *** ../vim-8.2.1951/src/version.c 2020-11-04 12:23:01.328933876 +0100 --- src/version.c 2020-11-04 13:38:05.237523193 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1952, /**/ -- hundred-and-one symptoms of being an internet addict: 195. Your cat has its own home page. /// 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 ///