diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-06-12 12:16:55 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-06-12 12:16:55 +0200 |
commit | 22db0d549f64aa3d8a6e366b70eb8d7e66933b82 (patch) | |
tree | 452b275fdd0cb175cce79982b1688ae1bbbc7434 | |
parent | 8de901e1f1b051e02a61ae76ad7c925e4c0642e5 (diff) | |
download | vim-git-22db0d549f64aa3d8a6e366b70eb8d7e66933b82.tar.gz |
patch 8.2.2977: crash when using a null function referencev8.2.2977
Problem: Crash when using a null function reference. (Naohiro Ono)
Solution: Check for an invalid function name. (closes #8367)
-rw-r--r-- | src/errors.h | 2 | ||||
-rw-r--r-- | src/eval.c | 8 | ||||
-rw-r--r-- | src/testdir/test_functions.vim | 4 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 15 insertions, 1 deletions
diff --git a/src/errors.h b/src/errors.h index fac3e26d8..63e2659f7 100644 --- a/src/errors.h +++ b/src/errors.h @@ -425,3 +425,5 @@ EXTERN char e_nr_arguments_too_few[] 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")); diff --git a/src/eval.c b/src/eval.c index b6bee5af5..0d15a70e2 100644 --- a/src/eval.c +++ b/src/eval.c @@ -3772,7 +3772,14 @@ call_func_rettv( 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,6 +3793,7 @@ call_func_rettv( 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) diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 130955439..d63bec498 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -2174,9 +2174,11 @@ func Test_call() call assert_fails("call call('Mylen', [], 0)", 'E715:') call assert_fails('call foo', 'E107:') - " This once caused a crash. + " 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() diff --git a/src/version.c b/src/version.c index 08f06cf4d..19a159d7e 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2977, +/**/ 2976, /**/ 2975, |