To: vim_dev@googlegroups.com Subject: Patch 8.2.1924 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1924 Problem: Vim9: crash when indexing dict with NULL key. Solution: Use empty string instead of NULL. (closes #7229) Make error message more useful for empty string. Files: src/vim9execute.c, src/globals.h, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1923/src/vim9execute.c 2020-10-28 20:19:56.376057067 +0100 --- src/vim9execute.c 2020-10-30 18:26:34.695941577 +0100 *************** *** 2607,2612 **** --- 2607,2614 ---- tv = STACK_TV_BOT(-1); // no need to check for VAR_STRING, 2STRING will check. key = tv->vval.v_string; + if (key == NULL) + key = (char_u *)""; if ((di = dict_find(dict, key, -1)) == NULL) { *** ../vim-8.2.1923/src/globals.h 2020-10-28 20:19:56.368057090 +0100 --- src/globals.h 2020-10-30 18:27:17.023799293 +0100 *************** *** 1699,1705 **** EXTERN char e_toomanyarg[] INIT(= N_("E118: Too many arguments for function: %s")); EXTERN char e_toofewarg[] INIT(= N_("E119: Not enough arguments for function: %s")); EXTERN char e_func_deleted[] INIT(= N_("E933: Function was deleted: %s")); ! EXTERN char e_dictkey[] INIT(= N_("E716: Key not present in Dictionary: %s")); EXTERN char e_listreq[] INIT(= N_("E714: List required")); EXTERN char e_listblobreq[] INIT(= N_("E897: List or Blob required")); EXTERN char e_list_end[] INIT(= N_("E697: Missing end of List ']': %s")); --- 1699,1705 ---- EXTERN char e_toomanyarg[] INIT(= N_("E118: Too many arguments for function: %s")); EXTERN char e_toofewarg[] INIT(= N_("E119: Not enough arguments for function: %s")); EXTERN char e_func_deleted[] INIT(= N_("E933: Function was deleted: %s")); ! EXTERN char e_dictkey[] INIT(= N_("E716: Key not present in Dictionary: \"%s\"")); EXTERN char e_listreq[] INIT(= N_("E714: List required")); EXTERN char e_listblobreq[] INIT(= N_("E897: List or Blob required")); EXTERN char e_list_end[] INIT(= N_("E697: Missing end of List ']': %s")); *** ../vim-8.2.1923/src/testdir/test_vim9_expr.vim 2020-10-22 20:09:37.478801896 +0200 --- src/testdir/test_vim9_expr.vim 2020-10-30 18:32:08.290853640 +0100 *************** *** 1917,1922 **** --- 1917,1923 ---- CheckDefExecFailure(['var x: dict = #{a: "x", b: 134}'], 'E1012:', 1) CheckDefFailure(['var x = ({'], 'E723:', 2) + CheckDefExecFailure(['{}[getftype("")]'], 'E716: Key not present in Dictionary: ""', 1) enddef def Test_expr7_dict_vim9script() *** ../vim-8.2.1923/src/version.c 2020-10-29 20:24:31.556056458 +0100 --- src/version.c 2020-10-30 18:28:39.835524878 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1924, /**/ -- hundred-and-one symptoms of being an internet addict: 156. You forget your friend's name but not her e-mail address. /// 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 ///