]> granicus.if.org Git - vim/commitdiff
patch 8.2.2977: crash when using a null function reference v8.2.2977
authorBram Moolenaar <Bram@vim.org>
Sat, 12 Jun 2021 10:16:55 +0000 (12:16 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 12 Jun 2021 10:16:55 +0000 (12:16 +0200)
Problem:    Crash when using a null function reference. (Naohiro Ono)
Solution:   Check for an invalid function name. (closes #8367)

src/errors.h
src/eval.c
src/testdir/test_functions.vim
src/version.c

index fac3e26d8b6239268c585e7aa100a311b8e99995..63e2659f73337476597f9389ab3408cae61a5d88 100644 (file)
@@ -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"));
index b6bee5af50cca04c5f8c8f3f0013d946b7792b52..0d15a70e2bbf55283c6bfa4f1fa835b7252773e2 100644 (file)
@@ -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)
index 1309554395316cb006ef52802a32b3465b4c2f72..d63bec498e0733afbf6a4b54bbb6dae0fe268e81 100644 (file)
@@ -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()
index 08f06cf4dc2926ff0dddf752c3f4fa6d266c936e..19a159d7edd7606e8b7284fb7d58db98b3f178fe 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2977,
 /**/
     2976,
 /**/