]> granicus.if.org Git - vim/commitdiff
patch 8.2.1802: Vim9: crash with unterminated dict v8.2.1802
authorBram Moolenaar <Bram@vim.org>
Mon, 5 Oct 2020 17:23:59 +0000 (19:23 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 5 Oct 2020 17:23:59 +0000 (19:23 +0200)
Problem:    Vim9: crash with unterminated dict. (Dhiraj Mishra)
Solution:   Return empty string instead of NULL. (closes #7084)

src/testdir/test_vim9_expr.vim
src/version.c
src/vim9compile.c

index 2cbb2854a69832248dd462765cc1db38cd2a5225..9292a77d6dc597e4f9614e144debdeb68c8006c2 100644 (file)
@@ -1819,6 +1819,8 @@ def Test_expr7_dict()
   CheckDefExecFailure(['var x: dict<number> = #{a: "x", b: 134}'], 'E1012:', 1)
   CheckDefExecFailure(['var x: dict<string> = #{a: 234, b: "1"}'], 'E1012:', 1)
   CheckDefExecFailure(['var x: dict<string> = #{a: "x", b: 134}'], 'E1012:', 1)
+
+  CheckDefFailure(['var x = ({'], 'E723:', 2)
 enddef
 
 def Test_expr7_dict_vim9script()
index 80b93196fe1598dee00242a540900a470c2ae22e..244c26d09fa564ad6fdb13d0427ce725c19b7bc9 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1802,
 /**/
     1801,
 /**/
index 373d76c6e21c41bcdd65db5584da96a14bc7b1e0..a6bdcc3f3df56c78a3c1988221045c6823540cbe 100644 (file)
@@ -2822,7 +2822,10 @@ compile_dict(char_u **arg, cctx_T *cctx, int literal)
 
 failret:
     if (*arg == NULL)
+    {
        semsg(_(e_missing_dict_end), _("[end of lines]"));
+       *arg = (char_u *)"";
+    }
     dict_unref(d);
     return FAIL;
 }