mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	vim-patch:8.2.2977: crash when using a null function reference
Problem:    Crash when using a null function reference. (Naohiro Ono)
Solution:   Check for an invalid function name. (closes vim/vim#8367)
22db0d549f
Co-authored-by: Bram Moolenaar <Bram@vim.org>
			
			
This commit is contained in:
		| @@ -139,7 +139,7 @@ You will not get an error if you try to change the type of a variable. | |||||||
|  |  | ||||||
|  |  | ||||||
| 1.2 Function references ~ | 1.2 Function references ~ | ||||||
| 							*Funcref* *E695* *E718* | 					*Funcref* *E695* *E718* *E1192* | ||||||
| A Funcref variable is obtained with the |function()| function, the |funcref()| | A Funcref variable is obtained with the |function()| function, the |funcref()| | ||||||
| function or created with the lambda expression |expr-lambda|.  It can be used | function or created with the lambda expression |expr-lambda|.  It can be used | ||||||
| in an expression in the place of a function name, before the parenthesis | in an expression in the place of a function name, before the parenthesis | ||||||
|   | |||||||
| @@ -96,6 +96,7 @@ static const char *e_string_list_or_blob_required = N_("E1098: String, List or B | |||||||
| static const char e_expression_too_recursive_str[] = N_("E1169: Expression too recursive: %s"); | static const char e_expression_too_recursive_str[] = N_("E1169: Expression too recursive: %s"); | ||||||
| static const char e_dot_can_only_be_used_on_dictionary_str[] | static const char e_dot_can_only_be_used_on_dictionary_str[] | ||||||
|   = N_("E1203: Dot can only be used on a dictionary: %s"); |   = N_("E1203: Dot can only be used on a dictionary: %s"); | ||||||
|  | static const char e_empty_function_name[] = N_("E1192: Empty function name"); | ||||||
|  |  | ||||||
| static char * const namespace_char = "abglstvw"; | static char * const namespace_char = "abglstvw"; | ||||||
|  |  | ||||||
| @@ -3273,6 +3274,10 @@ static int call_func_rettv(char **const arg, evalarg_T *const evalarg, typval_T | |||||||
|       funcname = is_lua ? lua_funcname : partial_name(pt); |       funcname = is_lua ? lua_funcname : partial_name(pt); | ||||||
|     } else { |     } else { | ||||||
|       funcname = functv.vval.v_string; |       funcname = functv.vval.v_string; | ||||||
|  |       if (funcname == NULL || *funcname == NUL) { | ||||||
|  |         emsg(_(e_empty_function_name)); | ||||||
|  |         goto theend; | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   } else { |   } else { | ||||||
|     funcname = ""; |     funcname = ""; | ||||||
| @@ -3288,6 +3293,7 @@ static int call_func_rettv(char **const arg, evalarg_T *const evalarg, typval_T | |||||||
|   const int ret = get_func_tv(funcname, is_lua ? (int)(*arg - funcname) : -1, rettv, |   const int ret = get_func_tv(funcname, is_lua ? (int)(*arg - funcname) : -1, rettv, | ||||||
|                               arg, evalarg, &funcexe); |                               arg, evalarg, &funcexe); | ||||||
|  |  | ||||||
|  | theend: | ||||||
|   // Clear the funcref afterwards, so that deleting it while |   // Clear the funcref afterwards, so that deleting it while | ||||||
|   // evaluating the arguments is possible (see test55). |   // evaluating the arguments is possible (see test55). | ||||||
|   if (evaluate) { |   if (evaluate) { | ||||||
|   | |||||||
| @@ -2010,11 +2010,15 @@ func Test_call() | |||||||
|   call assert_fails("call call('Mylen', [], 0)", 'E715:') |   call assert_fails("call call('Mylen', [], 0)", 'E715:') | ||||||
|   call assert_fails('call foo', 'E107:') |   call assert_fails('call foo', 'E107:') | ||||||
|  |  | ||||||
|   " This once caused a crash. |   " These once caused a crash. | ||||||
|   " Nvim doesn't have null functions |   " Nvim doesn't have null functions | ||||||
|   " call call(test_null_function(), []) |   " call call(test_null_function(), []) | ||||||
|   " Nvim doesn't have null partials |   " Nvim doesn't have null partials | ||||||
|   " call call(test_null_partial(), []) |   " call call(test_null_partial(), []) | ||||||
|  |   " Nvim doesn't have null functions | ||||||
|  |   " call assert_fails('call test_null_function()()', 'E1192:') | ||||||
|  |   " Nvim doesn't have null partials | ||||||
|  |   " call assert_fails('call test_null_partial()()', 'E117:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_char2nr() | func Test_char2nr() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 zeertzjq
					zeertzjq