]> granicus.if.org Git - vim/commitdiff
patch 8.2.2537: Vim9: crash when map() fails v8.2.2537
authorBram Moolenaar <Bram@vim.org>
Sun, 21 Feb 2021 15:20:18 +0000 (16:20 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 21 Feb 2021 15:20:18 +0000 (16:20 +0100)
Problem:    Vim9: crash when map() fails.
Solution:   Clear typval before using it. (closes #7884)

src/list.c
src/testdir/test_vim9_builtin.vim
src/version.c

index 2af3085cc304db859c91594c77407ff5fc2d9e66..b1080dee0f578aa1f735bbe6676588250fbb0e57 100644 (file)
@@ -2145,6 +2145,7 @@ filter_map(typval_T *argvars, typval_T *rettv, filtermap_T filtermap)
                                                           arg_errmsg, TRUE)))
                        break;
                    set_vim_var_string(VV_KEY, di->di_key, -1);
+                   newtv.v_type = VAR_UNKNOWN;
                    r = filter_map_one(&di->di_tv, expr, filtermap,
                                                                 &newtv, &rem);
                    clear_tv(get_vim_var_tv(VV_KEY));
index cb36990657b574d893b816ad3d74b9597aea4025..3ee8a620f6fb230212745382b0fb665d0c53e91f 100644 (file)
@@ -690,6 +690,27 @@ def Test_maparg_mapset()
   nunmap <F3>
 enddef
 
+def Test_map_failure()
+  CheckFeature job
+
+  var lines =<< trim END
+      vim9script
+      writefile([], 'Xtmpfile')
+      silent e Xtmpfile
+      var d = {[bufnr('%')]: {a: 0}}
+      au BufReadPost * Func()
+      def Func()
+          if d->has_key('')
+          endif
+          eval d[expand('<abuf>')]->mapnew((_, v: dict<job>) => 0)
+      enddef
+      e
+  END
+  CheckScriptFailure(lines, 'E1013:')
+  au! BufReadPost
+  delete('Xtmpfile')
+enddef
+
 def Test_max()
   g:flag = true
   var l1: list<number> = g:flag
index 3f5ae9d8cc0407cea2acda0b5af6a754391cc86c..8d29d52181691b6418f96dbad6e79b4db75316fa 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2537,
 /**/
     2536,
 /**/