]> granicus.if.org Git - vim/commitdiff
patch 8.2.2190: Vim9: crash when compiled with EXITFREE v8.2.2190
authorBram Moolenaar <Bram@vim.org>
Tue, 22 Dec 2020 17:33:27 +0000 (18:33 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 22 Dec 2020 17:33:27 +0000 (18:33 +0100)
Problem:    Vim9: crash when compiled with EXITFREE.
Solution:   Check that df_ufunc is not NULL.

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

index 015fe3d55bc82a219b0c7e1bf87c4c28043c9bfe..3b57e312b8cac7f390c3933c12a5b4eddf11030b 100644 (file)
@@ -2011,5 +2011,27 @@ def Test_opfunc()
   nunmap <F3>
 enddef
 
+" this was crashing on exit
+def Test_nested_lambda_in_closure()
+  var lines =<< trim END
+      vim9script
+      def Outer()
+          def g:Inner()
+              echo map([1, 2, 3], {_, v -> v + 1})
+          enddef
+          g:Inner()
+      enddef
+      defcompile
+      writefile(['Done'], 'XnestedDone')
+      quit
+  END
+  if !RunVim([], lines, '--clean')
+    return
+  endif
+  assert_equal(['Done'], readfile('XnestedDone'))
+  delete('XnestedDone')
+enddef
+
+
 
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
index 65dfcdfaefb800094def7831d2dc27647687ca51..427c8f8a7f623f36746f71d8a4418d75b9fd8053 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2190,
 /**/
     2189,
 /**/
index 8e07968ce4edf3bb26433fa13d1d73ad293c7f4a..7ee15fe2759774036db58d0221533d359ffda1e8 100644 (file)
@@ -8081,9 +8081,10 @@ delete_instr(isn_T *isn)
            {
                dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
                                               + isn->isn_arg.funcref.fr_func;
+               ufunc_T *ufunc = dfunc->df_ufunc;
 
-               if (func_name_refcount(dfunc->df_ufunc->uf_name))
-                   func_ptr_unref(dfunc->df_ufunc);
+               if (ufunc != NULL && func_name_refcount(ufunc->uf_name))
+                   func_ptr_unref(ufunc);
            }
            break;