Patch 8.2.2977

2 views
Skip to first unread message

Bram Moolenaar

unread,
Jun 12, 2021, 6:17:28 AM6/12/21
to vim...@googlegroups.com

Patch 8.2.2977
Problem: Crash when using a null function reference. (Naohiro Ono)
Solution: Check for an invalid function name. (closes #8367)
Files: src/eval.c, src/errors.h, src/testdir/test_functions.vim


*** ../vim-8.2.2976/src/eval.c 2021-06-09 20:50:42.255103073 +0200
--- src/eval.c 2021-06-12 12:12:00.499848345 +0200
***************
*** 3772,3778 ****
--- 3772,3785 ----
s = partial_name(pt);
}
else
+ {
s = functv.vval.v_string;
+ if (s == NULL || *s == NUL)
+ {
+ emsg(_(e_empty_function_name));
+ goto theend;
+ }
+ }
}
else
s = (char_u *)"";
***************
*** 3786,3791 ****
--- 3793,3799 ----
funcexe.basetv = basetv;
ret = get_func_tv(s, -1, rettv, arg, evalarg, &funcexe);

+ theend:
// Clear the funcref afterwards, so that deleting it while
// evaluating the arguments is possible (see test55).
if (evaluate)
*** ../vim-8.2.2976/src/errors.h 2021-06-08 22:01:48.750571749 +0200
--- src/errors.h 2021-06-12 12:13:27.759570632 +0200
***************
*** 425,427 ****
--- 425,429 ----
INIT(= N_("E1190: %d arguments too few"));
EXTERN char e_call_to_function_that_failed_to_compile_str[]
INIT(= N_("E1191: Call to function that failed to compile: %s"));
+ EXTERN char e_empty_function_name[]
+ INIT(= N_("E1192: Empty function name"));
*** ../vim-8.2.2976/src/testdir/test_functions.vim 2021-06-07 18:27:35.900235056 +0200
--- src/testdir/test_functions.vim 2021-06-12 12:16:04.131072904 +0200
***************
*** 2174,2182 ****
call assert_fails("call call('Mylen', [], 0)", 'E715:')
call assert_fails('call foo', 'E107:')

! " This once caused a crash.
call call(test_null_function(), [])
call call(test_null_partial(), [])
endfunc

func Test_char2nr()
--- 2174,2184 ----
call assert_fails("call call('Mylen', [], 0)", 'E715:')
call assert_fails('call foo', 'E107:')

! " These once caused a crash.
call call(test_null_function(), [])
call call(test_null_partial(), [])
+ call assert_fails('call test_null_function()()', 'E1192:')
+ call assert_fails('call test_null_partial()()', 'E117:')
endfunc

func Test_char2nr()
*** ../vim-8.2.2976/src/version.c 2021-06-11 22:21:20.715944455 +0200
--- src/version.c 2021-06-12 12:12:41.131719025 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2977,
/**/

--
"The future's already arrived - it's just not evenly distributed yet."
-- William Gibson

/// 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