Navigation Menu

Skip to content

Commit

Permalink
patch 8.2.3847: illegal memory access when using a lambda with an error
Browse files Browse the repository at this point in the history
Problem:    Illegal memory access when using a lambda with an error.
Solution:   Avoid skipping over the NUL after a string.
  • Loading branch information
brammool committed Dec 18, 2021
1 parent 60618c8 commit 605ec91
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/eval.c
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/testdir/test_lambda.vim
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -749,6 +749,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3847,
/**/
3846,
/**/
Expand Down

0 comments on commit 605ec91

Please sign in to comment.