]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1884: :defer an empty lambda causes a crash v9.1.1884
authorYegappan Lakshmanan <yegappan@yahoo.com>
Tue, 28 Oct 2025 20:05:13 +0000 (20:05 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 28 Oct 2025 20:05:13 +0000 (20:05 +0000)
Problem:  :defer an empty lambda causes a crash
          (Maxim Kim, after v9.1.1882)
Solution: Check for missing arguments (Yegappan Lakshmanan)

related: #18641
closes: #18653

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_vim9_script.vim
src/version.c
src/vim9cmds.c

index 0134956c301fe9502a3de928e5241d8b522e7213..8de7bd3579a15fa946665028f5831aa3e224f950 100644 (file)
@@ -5343,6 +5343,18 @@ def Test_defer_lambda_func()
     defcompile
   END
   v9.CheckScriptFailure(lines, 'E1028: Compiling :def function failed', 1)
+
+  # Error: lambda without arguments
+  lines =<< trim END
+    vim9script
+    def Foo()
+      defer () => {
+      }
+      assert_report("shouldn't reach here")
+    enddef
+    defcompile
+  END
+  v9.CheckScriptFailure(lines, 'E107: Missing parentheses: ', 1)
 enddef
 
 " Test for using an non-existing type in a "for" statement.
index c34ae073497e1a68b45cae30a98dea781fca86e6..e225e9439bec57d29c56f3226e6edd05efb689a8 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1884,
 /**/
     1883,
 /**/
index 684d2ee66d643c53992eb5aae2fe557b53c059d4..d06759e80c180ecda83d35ec7a91ffbd6e0be87d 100644 (file)
@@ -2047,7 +2047,12 @@ compile_defer(char_u *arg_start, cctx_T *cctx)
        // a lambda function
        if (compile_lambda(&arg, cctx) != OK)
            return NULL;
-       paren = arg;
+       paren = vim_strchr(arg, '(');
+       if (paren == NULL)
+       {
+           semsg(_(e_missing_parenthesis_str), arg);
+           return NULL;
+       }
     }
     else
     {