Patch 8.2.4774

6 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 17, 2022, 10:10:50 AM4/17/22
to vim...@googlegroups.com

Patch 8.2.4774
Problem: Crash when using a number for lambda name.
Solution: Check the type of the lambda reference.
Files: src/eval.c, src/errors.h, src/testdir/test_lambda.vim


*** ../vim-8.2.4773/src/eval.c 2022-04-15 22:57:05.523488055 +0100
--- src/eval.c 2022-04-17 15:02:15.862629448 +0100
***************
*** 4102,4120 ****
++*arg;
ret = eval1(arg, rettv, evalarg);
*arg = skipwhite_and_linebreak(*arg, evalarg);
! if (**arg == ')')
{
! ++*arg;
}
! else
{
! emsg(_(e_missing_closing_paren));
! ret = FAIL;
}
}
if (ret != OK)
return FAIL;
! else if (**arg != '(')
{
if (verbose)
{
--- 4102,4124 ----
++*arg;
ret = eval1(arg, rettv, evalarg);
*arg = skipwhite_and_linebreak(*arg, evalarg);
! if (**arg != ')')
{
! emsg(_(e_missing_closing_paren));
! return FAIL;
}
! if (rettv->v_type != VAR_STRING && rettv->v_type != VAR_FUNC
! && rettv->v_type != VAR_PARTIAL)
{
! emsg(_(e_string_or_function_required_for_arrow_parens_expr));
! return FAIL;
}
+ ++*arg;
}
if (ret != OK)
return FAIL;
!
! if (**arg != '(')
{
if (verbose)
{
*** ../vim-8.2.4773/src/errors.h 2022-04-10 11:26:00.941539608 +0100
--- src/errors.h 2022-04-17 15:01:20.886635443 +0100
***************
*** 3259,3261 ****
--- 3259,3265 ----
INIT(= N_("E1273: (NFA regexp) missing value in '\\%%%c'"));
EXTERN char e_no_script_file_name_to_substitute_for_script[]
INIT(= N_("E1274: No script file name to substitute for \"<script>\""));
+ #ifdef FEAT_EVAL
+ EXTERN char e_string_or_function_required_for_arrow_parens_expr[]
+ INIT(= N_("E1275: String or function required for ->(expr)"));
+ #endif
*** ../vim-8.2.4773/src/testdir/test_lambda.vim 2021-12-18 16:54:28.363950392 +0000
--- src/testdir/test_lambda.vim 2022-04-17 15:05:19.806621567 +0100
***************
*** 66,71 ****
--- 66,75 ----
echo assert_fails('echo 10->{a -> a + 2}', 'E107:')

call assert_fails('eval 0->(', "E110: Missing ')'")
+ call assert_fails('eval 0->(3)()', "E1275:")
+ call assert_fails('eval 0->([3])()', "E1275:")
+ call assert_fails('eval 0->({"a": 3})()', "E1275:")
+ call assert_fails('eval 0->(xxx)()', "E121:")
endfunc

func Test_not_lamda()
*** ../vim-8.2.4773/src/version.c 2022-04-17 14:18:07.364733158 +0100
--- src/version.c 2022-04-17 15:06:05.250622046 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4774,
/**/

--
hundred-and-one symptoms of being an internet addict:
8. You spend half of the plane trip with your laptop on your lap...and your
child in the overhead compartment.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages