changeset 26636:6047c7ea7963 v8.2.3847

patch 8.2.3847: illegal memory access when using a lambda with an error Commit: https://github.com/vim/vim/commit/605ec91e5a7330d61be313637e495fa02a6dc264 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 18 16:54:31 2021 +0000 patch 8.2.3847: illegal memory access when using a lambda with an error Problem: Illegal memory access when using a lambda with an error. Solution: Avoid skipping over the NUL after a string.
author Bram Moolenaar <Bram@vim.org>
date Sat, 18 Dec 2021 18:00:03 +0100
parents 788251bf42b4
children eeac85e187e7
files src/eval.c src/testdir/test_lambda.vim src/version.c
diffstat 3 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -3871,12 +3871,15 @@ eval_lambda(
 	++*arg;
 	ret = eval1(arg, rettv, evalarg);
 	*arg = skipwhite_and_linebreak(*arg, evalarg);
-	if (**arg != ')')
+	if (**arg == ')')
+	{
+	    ++*arg;
+	}
+	else
 	{
 	    emsg(_(e_missing_closing_paren));
 	    ret = FAIL;
 	}
-	++*arg;
     }
     if (ret != OK)
 	return FAIL;
--- a/src/testdir/test_lambda.vim
+++ b/src/testdir/test_lambda.vim
@@ -64,6 +64,8 @@ function Test_lambda_fails()
   call assert_fails('echo {a, a -> a + a}(1, 2)', 'E853:')
   call assert_fails('echo {a, b -> a + b)}(1, 2)', 'E451:')
   echo assert_fails('echo 10->{a -> a + 2}', 'E107:')
+
+  call assert_fails('eval 0->(', "E110: Missing ')'")
 endfunc
 
 func Test_not_lamda()
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3847,
+/**/
     3846,
 /**/
     3845,